Unique name of uploaded files

If you want to prevent situation that you have the same name of upload files use this example: var fileToSave = ┬áDateTime.Now.ToString(“yyyyMMddHHmmssfff”) + “_” + Guid.NewGuid().ToString(“N”) + “-” + SomeYourModelsId + “.pdf”;  

Prevent duplicate records with seed

Prevent duplicate records when you use seed method in migration. Originally in Migrations/Configuration.cs we can use: context.People.AddOrUpdate( p => p.FullName, new Person { FullName = “Andrew Peters” }, new Person { FullName = “Brice Lambson” }, new Person { FullName = “Rowan Miller” } ); But when we configure adding record (like sample above) every […]

Bug dd.MM.yyyy format

For right validation of format date like: dd.MM.yyyy in MVC5 you need to do cuple of things. 1. In NuGet Menager Console install: Install-Package Moment.js 2. In _Layout.cshtml add: //At HEAD part add: @Scripts.Render(“~/Scripts/jquery.validate.min.js”) @Scripts.Render(“~/Scripts/jquery.validate.unobtrusive.min.js”) @Scripts.Render(“~/Scripts/moment.js”) 3. In menu Tools / Extensions and Updates install From jQuery-ui, add link to jquery-ui and script datepicker with […]