示例#1
0
        public ActionResult Create()
        {
            var model = new HeifersViewModel();

            model.StateSelectList = selectList;
            model.BirthDate       = DateTime.Today;
            return(View(model));
        }
示例#2
0
 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));
 }
示例#3
0
 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));
 }