Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
1
votes2
answers2093
viewsA: Send file from one server to another
On site X, implement the following: public FileResult DownloadArquivo() { // Abra o arquivo e o transforme em um Array de bytes return File(bytes, System.Net.Mime.MediaTypeNames.Application.Octet,…
-
0
votes2
answers1437
viewsA: How do I catch Id on the return of a Web Api Post?
If you only returned the whole, it would look like this: var retorno = response.Content.ReadAsAsync<int>().Result; But I think this way it can be a problem, because you created an anonymous…
-
3
votes1
answer2717
viewsA: How to save and return images with Web Api?
Save using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Net.Http.Headers; using…
-
1
votes1
answer695
viewsA: Error when calculating date difference in Entity with Linq to Entities
For the first mistake, change: .Where(dt => (TimeSpan)((dt.t1.DT_TransacaoV - DateTime.Now)).TotalDays > 45 For: .Where(dt => DbFunctions.DiffDays(dt.t1.DT_TransacaoV, DateTime.Now) > 45…
-
1
votes1
answer157
viewsA: Create a record and add relationship through the httpPost Web Api
Two ways: 1. Creating a Viewmodel identical to your Model, with one more parameter public class MenuProductViewMode { public int MenuIdAux { get; set; } // Coloque aqui os outros parâmetros do Model…
-
1
votes2
answers1443
viewsA: Move images on VB6
First I would abandon your variable Indo. In which case, I’d use a Enum: Enum Movimento Cima Baixo Esquerda Direita End Enum And declare a variable called mov: Dim mov as Movimento In this case, the…
-
4
votes1
answer338
viewsA: Create Web Service by repurposing code from an already published site. Good practices in Asp.NET MVC
How to enable your ASP.NET MVC5 application for Web API There are several tutorials on the internet, but I decided to do something very brief as a response. The rest is as a source of consultation.…
-
5
votes2
answers674
viewsA: Can you use a variable that’s inside the for?
Only declare the variable before, outside the for(). There are a few more changes that need to be made, as below: $todosNumeros = ""; $telefones = 3; for($i = 0; $i < $telefones; $i++) {…
-
1
votes3
answers679
viewsA: Error generating PDF with Rotary
I see no need to assemble the second object. Possibly it is causing the error. public ActionResult GeraPDF(long? id) { var aluno = db .Alunos .Include(x => x.Ocorrencias) .AsNoTracking()…
-
3
votes2
answers495
viewsA: Lambda Expression X
For the case of objects that implement IQueryable, there is the time of constructing the sentence that consumes some processing, therefore, starting from absolute terms, the sentence in static SQL…
-
1
votes2
answers147
viewsA: Use lambda with Ado.Net
Using sqldatareader and ado.net, you can use lambda with either single or single lambda? Yes What you call "lambda" is actually a parameter of the type Func<TSource, T>, which is a predicate.…
-
2
votes1
answer1300
viewsA: Calculate date difference and compare with integer field in lambda expression
Still picking up the days of the TimeSpan: var atendimento = db.T_CRM_StatusPDV .Where(dt => ((TimeSpan)(dt.DT_TransacaoV - DateTime.Now)).Days > dt.DE_FrequenciaTrans) Reference:…
-
3
votes4
answers2718
viewsA: Generate sequential Ids without losing the sequence
The best way to solve this is: Not using Identities. For this you will have to abandon sequential keys and go to random keys. No Entity Framework, the type of field is the Guid. The chance of…
-
2
votes2
answers8216
viewsA: How to use While in MYSQL
I don’t understand what you want to do, but your syntax is wrong. First you need to declare the variable to use, more or less like this: DECLARE c INT DEFAULT 5; while c > 1 select dia from…
mysqlanswered Leonel Sanches da Silva 88,623 -
1
votes1
answer276
viewsA: Going up Node.js project (with websocket) to Heroku
deploy occurred without errors. I tried to sign in to your website and had the following screen: To view error logs, use: heroku logs There’s more additional options here. EDIT Again, the error is…
-
4
votes1
answer159
viewsA: (ASP NET MVC4 or 5) How to pass a custom name to Xmlhttprequest?
Add to FormData: var formdata = new FormData(); formdata.append("Files", data); formdata.append("Nome", $("#Nome").val()); And to the Controller: [HttpPost] public ContentResult UploadFiles(String…
-
2
votes2
answers1937
viewsA: How to render html by passing as a controller string to the view?
Yes. Implement in your project the following extension: public static class ImageHelper { public static MvcHtmlString Image(this HtmlHelper helper, string src, string altText, string height, string…
-
2
votes4
answers2351
viewsA: Merge word docx documents from a template and replace words
There’s a discussion on the developer page in which they explain that this method is not good and that it should not be used. I would leave for another package. This one looked pretty promising:…
-
6
votes1
answer50
viewsA: Why is the default for an access modifier "protected" in . NET?
The default access modifier for a class is not the protected. Is the internal. The default access modifier for a class method is the private. According to answer from Jon Skeet, this is due to the…
.netanswered Leonel Sanches da Silva 88,623 -
19
votes1
answer1772
viewsA: Is Nosql synonymous with an Object-Oriented Database?
There is a confusion of concepts here in your question. But answering in essence, no, they’re not synonymous. Nosql designates databases using technologies other than a relational database, not…
-
2
votes1
answer129
viewsA: In the table Insert is inserting everything, until what I do not want
The problem is that you are opening two objects in theory highlighted from the context, here: foreach (var lista in acao) { osParceiro.AcaoParceiro = lista.Acao; osParceiro.ProximaAcao =…
-
3
votes2
answers7771
viewsA: Pass parameter (a list object) from View (List type) to Controller. Asp.NET MVC
Don’t go through the ActionLink the whole object. Pass only the Id of the object. Do the Binding of an entire object is very laborious and has a good chance of not working. Change:…
-
15
votes4
answers5615
viewsA: What is the difference in the use of the Equals method for the ==operator?
Basically it works like this: Whether the type is primitive (i.e., Boolean (bool), Byte (byte), SByte (sbyte), Int16 (short), UInt16, Int32 (int), Uint32 (uint), Int64 (long), Uint64 (ulong),…
-
7
votes2
answers1552
viewsA: Clause in with lambda
More or less. The way to do it is like this: var inteirosPraAchar = new List<int> {2, 3, 4, 5}; context.tabela.Where(a => inteirosPraAchar.Contains(a.meu_campo_id_tipo_inteiro));…
-
1
votes1
answer2118
viewsA: How to fix the error: Schema specified is not Valid
The section <entityFramework> is wrong. Modify to: <entityFramework> <providers> <provider invariantName="MySql.Data.MySqlClient"…
-
3
votes2
answers6164
viewsA: Grab information from object Sender
The sender should be understood as a joking object: the idea of it not being typed is precisely so that it can be manipulated by events in which the object types are different, and that a single…
-
2
votes2
answers383
viewsA: Getting around the problem with hot Java development?
There is a product called Jrebel that enables Tomcat to work in continuous Deployment mode: http://zeroturnaround.com/software/jrebel/ It is proprietary but has a trial version. The support is quite…
-
2
votes1
answer760
viewsA: Going up Ruby on Rails app in Heroku
The mistake is clear. Gemfile.lock required. Please check it in. Before you push again, run: bundle install In the case of the second pointed error, first execute this command: gem install sqlite3…
-
2
votes1
answer220
viewsA: How to list related data
Explicit load of occurrences was missing. Modify your Action of details for the following: [PermissionAttribute("Administrador,Coordenador")] // GET: /Alunos/Detalhes/5 public ActionResult…
-
6
votes3
answers9298
viewsA: Return the previous page with the back button
You can do the following: @Html.ActionLink("Voltar", "ActionDeVoltar", "ControllerQualquer", new { returnUrl = this.Request.UrlReferrer }, null) Put in your Controller common a Action thus: public…
-
12
votes1
answer10316
viewsA: How to fix Entityvalidationerrors
Create in your context the following: public class MeuProjetoContext : DbContext { public override int SaveChanges() { try { return base.SaveChanges(); } catch (DbEntityValidationException e) {…
-
35
votes1
answer8090
viewsA: Internationalization using ASP.Net MVC
There are some ways: 1. Using a File of Resource, manual mode This method is the simplest to internationalize your client-side and server-side application and usage. Has median complexity regarding…
-
4
votes4
answers438
viewsA: "Clean" way to modify the "Visible" attribute of a Picturebox
Thus: private void radioButtonUnico_CheckedChanged(object sender, EventArgs e) { pictureBox1.Visible = false; pictureBox2.Visible = false; pictureBox3.Visible = false; pictureBox4.Visible = false;…
-
2
votes2
answers921
viewsA: Recover Data Redirectaction mvc#
This code is very wrong. TempData should not be used to send information from a survey to the View. Create a ViewModel for the Student: Viewmodels Estudanteviewmodel public class EstudanteViewModel…
-
2
votes1
answer122
viewsA: Save to Database at auction end
In the jQuery Countdown documentation, there is a parameter called expiryUrl. It can be used to make an Ajax request for some Controller your. <script type="text/javascript">…
-
5
votes4
answers8104
viewsA: How do I make a connected Dropdownlist with a model property?
Use @DropDownListFor: @Html.DropDownList(model => model.TopicoId, ((IEnumerable)ViewBag.Topicos).Select(option => new SelectListItem { Text = option.Nome, Value = option.Id.Value, Selected =…
-
3
votes2
answers1276
viewsA: How to upgrade my Node.js project to Heroku?
Open an account on Heroku Is windows? Install the Heroku Toolbelt Log in, by typing heroku login in the shell Create the project by typing heroku create in the shell If it doesn’t exist, create a…
-
26
votes3
answers24262
viewsA: What is the difference between Ienumerable, Iqueryable and List?
IQueryable is a more specific interface that has a query provider, such as LINQ-To-SQL. It is a special object, that when using a method, it generates a query or a query structure for a database and…
-
3
votes1
answer262
viewsA: Entity framework does not create mdf file
To recreate the MDF, right-click the project > Add > New Item, and choose the option Service Based Database or else Service-Based Database: Migrations should work normally. Just run that…
-
10
votes1
answer1708
viewsA: ASP.NET Identity and Claims
What is this about? Claims are portions of data that form an identity. An identity is any and all information used to uniquely identify a user. A basic implementation for teaching purposes Here has…
-
2
votes1
answer123
viewsA: Customize windows authentication
Make another Action, for example, Details, in his Controller: public ActionResult Usuario(String userName) { var chapa = UserDetails.GetChapa(userName); var perfil = db.Perfis.FirstOrDefault(x =>…
-
18
votes3
answers27590
viewsA: How to encrypt and decrypt MD5 data using C#?
MD5 is not reversible, that is, it is only possible to create the hash (or, as you said, encrypt) and compare with another hash. If they are equal, the password entered is considered the same.…
-
2
votes1
answer62
viewsA: I can’t get into the comic book with Entity
The message says it all. The context expects a T_OsParceiro. You’re passing a PDVOsParceiro. The right thing would be: public int abreOsParceiro(string os, string cnpj, string dataAbertura, string…
-
1
votes2
answers1215
viewsA: Is it possible to assign Objectid() to subcollections in Mongodb?
It is possible to add ObjectId() in subcollections (or rather subdocuments)? Yes, but this is not very recommended, because considering that the data architecture decision was to put the data as a…
-
4
votes4
answers1399
viewsA: Databases for different customers
Two scenarios: 1. A system, accessing several databases Set a context for each database: public class Cliente1Context : DbContext { public Cliente1Context() : base("ConnectionStringDoCliente1") {}…
-
5
votes3
answers3330
viewsA: Grab ID immediately after insertion
The Entity Framework does this for you alone. Here’s an example: var registroDaMinhaEntidade = new Entidade { Propriedade = "Uma propriedade qualquer, sei lá" };…
-
6
votes2
answers874
viewsA: Hide different options (actions) for different user profiles
Whereas your project uses at least Membership or ASP.NET Identity, write down on top of each View the following attribute: [Authorize(Roles = "Administrador, Professor, Coordenador")] public…
-
4
votes4
answers33983
viewsA: How to copy column data from one table to another table
I think we missed the COMMIT at the end: update uc set uc.email = backup.email from backup where uc.idconsumidor = backup.idconsumidor; commit;
-
2
votes2
answers1328
viewsA: How to make a user helper logged in to Asp.NET MVC 4?
Follows a Helper I did to get logged in user information. This project uses Membership, that is, it is an old approach, but serves as an example for improvements in the case of ASP.NET Identity:…
-
3
votes1
answer1289
viewsA: Customizing Asp.net Identity - Multiple classes as User in Identity
Two ways to solve: 1. Make Client inherit direct from Identityuser public class Cliente : IdentityUser { [CNPJ] public string CNPJ { get; set; } } 2. Place CNPJ directly on Applicationuser public…