public ActionResult AddLivestock(LivestockViewModel model) { if (ModelState.IsValid) { try { // TODO: Add insert logic here var Livestock = new Livestock { Name = model.Name, PhotoPath = "upload.png", Description = model.Description, DateCreated = DateTime.Now, }; Livestock = LivestockService.Create(Livestock); if (Livestock != null) { SaveLivestockImage(Livestock); } return(RedirectToAction("Index", "Farm")); } catch { return(View()); } } return(View()); }
// GET: Livestock/Create public ActionResult AddLivestock() { var model = new LivestockViewModel { }; return(View(model)); }
// GET: Livestock public ActionResult Index() { var model = new LivestockViewModel { AllLivestock = LivestockService.Get().ToList() }; return(View(model)); }
public ActionResult PriceDetail(int?farmLivestockId) { FarmLivestock fLivestock = FarmLivestockService.GetById(farmLivestockId); LivestockViewModel model = new LivestockViewModel { Photopath = fLivestock.LivestockBreed.PhotoPath, Name = fLivestock.LivestockBreed.Name, BreedNote = fLivestock.LivestockBreed.Note, PriceDetail = fLivestock.LivestockPrice, farmLivestock = fLivestock }; return(View(model)); }
public ActionResult EditLivestock(LivestockViewModel model) { try { var Livestock = LivestockService.GetById(model.Id); Livestock.Name = model.Name; Livestock.Description = model.Description; Livestock.PhotoPath = "fm.jpg"; LivestockService.Update(Livestock); SaveLivestockImage(Livestock); return(RedirectToAction("Index")); } catch { return(View()); } }