public ActionResult Create(FormationVM FormationVM, HttpPostedFileBase Affiche) { if (!ModelState.IsValid || Affiche == null || Affiche.ContentLength == 0) { RedirectToAction("Create"); } Formation FormationDomain = new Formation() { Title = FormationVM.Title, Start = DateTime.UtcNow, End = FormationVM.End, Description = FormationVM.Description, Affiche = Affiche.FileName, NbrMax = FormationVM.NbrMax, Theme = FormationVM.Theme, Location = FormationVM.Location, Price = FormationVM.Price, // nomuser = User.Identity.GetUserName(), UserId = "f43c21cf-f35a-4897-a9e3-343c00afe7b3" }; MyFormationService.Add(FormationDomain); MyFormationService.Commit(); var path = Path.Combine(Server.MapPath("~/Content/Uploads"), Affiche.FileName); Affiche.SaveAs(path); return(RedirectToAction("Index")); }
static void Main(string[] args) { FormationService ps = new FormationService(); Producteur p = new Producteur { Nom = "test", prenom = "test", DateNaissance = DateTime.Now }; ps.Add(p); ps.Commit(); CandiratService fs = new CandiratService(); Film f = new Film { Titre = "film1", Description = "Test", // DateProd = DateTime.Now, DateProd = new DateTime(2016, 1, 1, 12, 00, 00), Price = 15, Genre = "Action", Evaluation = "Super", //avec validation // Genre = "ok", //Evaluation = "suoer", ImageUrl = "image", ProducteurId = 1 }; fs.Add(f); fs.Commit(); }