public ActionResult Create([Bind(Include = "Id,Name,LastName,BirthDate,Email,Password,Phone,Mobile,Department,Role,HireDate,TerminationDate,BaseSalary,Address,Address2,SSN,CURP,CLABE")] Employee employee) { if (ModelState.IsValid) { db.Employees.Add(employee); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employee)); }
public ActionResult Create([Bind(Include = "Id,Code,Amount,Description,ExpirationDate,CreatedDate,Type")] PromoCode promoCode) { if (ModelState.IsValid) { db.PromoCodes.Add(promoCode); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(promoCode)); }
public ActionResult Create([Bind(Include = "Id,Name,LastName,Email,Password,BirthDate,ContactNumber")] ClientViewModel clientVM, FormCollection form) { var cityId = Convert.ToInt32(form["City"]); if (db.Cities.Any(c => c.Id == cityId)) { var city = db.Cities.First(c => c.Id == cityId); clientVM.City = city; } var mapper = new ClientMapper(); var client = mapper.ClientViewModelToClient(clientVM); //éste método se utiliza para convertir el objeto ClientViewModel en un objeto Client if (ModelState.IsValid) { db.Clients.Add(client); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(clientVM)); }