public ActionResult Create() { var model = new HeifersViewModel(); model.StateSelectList = selectList; model.BirthDate = DateTime.Today; return(View(model)); }
public ActionResult Edit(int id, HeifersViewModel model) { model.StateSelectList = selectList; if (ModelState.IsValid) { Cattle heifer = mapper.Map <Cattle>(model); heifer.Id = id; heifer.CattleTypeId = (int)CattleTypes.Heifer; db.Repository.Update(heifer); db.Commit(); return(RedirectToAction("Index", "Heifers")); } return(View(model)); }
public ActionResult Create(HeifersViewModel model) { model.StateSelectList = selectList; if (ModelState.IsValid) { Cattle heifer = mapper.Map <Cattle>(model); heifer.CattleTypeId = (int)CattleTypes.Heifer; heifer.Sex = (int)Sex.Female; db.Repository.Add(heifer); db.Commit(); return(RedirectToAction("Index", "Heifers")); } return(View(model)); }