// GET: Livestock/Add livestock to farm //public ActionResult AddFarmLivestock(int? farmId) //{ // var model = new LivestockViewModel // { // LivestockListItem = GetLivestockList() // }; // return PartialView("_AddLivestockToFarmDialog", model); //} // GET: Pricing/Create public ActionResult AddLivestockPrice(int?farmLivestockId, int?farmId) { var model = new LivestockPriceViewModel { FarmLivestockId = farmLivestockId.Value, FarmId = farmId.Value, MeasurementDropDown = GetMeasurement(null) }; return(View(model)); }
public ActionResult AddLivestockPrice(LivestockPriceViewModel model) { if (ModelState.IsValid) { var pricing = new LivestockPrice { MeasurementId = model.MeasurementId, UnitPrice = model.UnitPrice, DateCreated = DateTime.Now }; LivestockPriceService.Create(pricing); return(RedirectToAction("Index", "FarmLivestock")); } return(RedirectToAction("Index", "FarmLivestock")); }
public ActionResult AddLivestockPrice(LivestockPriceViewModel model) { if (ModelState.IsValid) { var pricing = new LivestockPrice { MeasurementId = model.MeasurementId, UnitPrice = model.UnitPrice, DateCreated = DateTime.Now }; LivestockPrice livestockPrice = LivestockPriceService.Create(pricing); if (livestockPrice != null) { FarmLivestock updateFarmLivestock = FarmLivestockService.Get().Where(x => x.FarmId == model.FarmId).FirstOrDefault(); updateFarmLivestock.LivestockPriceId = livestockPrice?.Id; } return(RedirectToAction("Index", "Livestock")); } return(RedirectToAction("Index", "Livestock")); }