// GET: Locations/Edit/5 public ActionResult Edit(int?id) { if (!id.HasValue) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var location = m_repo.GetLocation(id.Value); var locationVM = LocationViewModel.Create(location); return(View(locationVM)); }
public void SaveOrder(OrderViewModel order) { var newOrder = OrderViewModel.ToOrder(order); if (newOrder.Genus == null) { newOrder.Genus = u_repo.GetGenus(newOrder.GenusId); } if (newOrder.Location == null && newOrder.LocationId.HasValue) { newOrder.Location = u_repo.GetLocation(newOrder.LocationId.Value); } if (newOrder.Location != null && newOrder.Location.PrimaryContactId.HasValue) { newOrder.Grower = u_repo.GetGrower(newOrder.Location.PrimaryContactId.Value); } else if (newOrder.Grower == null) { newOrder.Grower = u_repo.GetGrower(newOrder.GrowerId); } u_repo.SaveOrder(newOrder); var newOrderVm = OrderViewModel.Create(newOrder); newOrderVm.CopyTo(order); }
public ActionResult Create(MapQuestionListViewModel model) { int genusId = SessionManager.GetGenusId().Value; if (ModelState.IsValid) { map_repo.CreateMap(model); return(RedirectToAction("Details", new { id = model.Map.Id })); } if (model.Map != null & model.Map.LocationId.HasValue) { model.Map.Location = m_repo.GetLocation(model.Map.LocationId.Value); } var crossTypes = m_repo.GetCrossTypes().Where(t => t.GenusId == model.Map.GenusId && t.Retired == false); ViewBag.CrossTypes = new SelectList(crossTypes, "Id", "Name", model.Map.CrossTypeId); return(View(model)); }