public ActionResult Create(DistributorViewModel distributor) { if (ModelState.IsValid) { distributor.Id = Guid.NewGuid(); // temp: make sure website doesn't start with http(s):// if (!string.IsNullOrEmpty(distributor.Website) && distributor.Website.ToLower().StartsWith("http")) distributor.Website = new Uri(distributor.Website).Host + new Uri(distributor.Website).PathAndQuery; // convert to db type Distributor newDistributor = Mapper.Map<DistributorViewModel, Distributor>(distributor); _dataContext.Distributors.Add(newDistributor); _dataContext.SaveChanges(); return RedirectToAction("Index"); } return View(distributor); }
public ActionResult Edit(DistributorViewModel distributor) { // temp don't edit return RedirectToAction("Index"); /*if (ModelState.IsValid) { var editDistributor = _dataContext.Distributors.Find(distributor.Id); editDistributor.Address.Line1 = distributor.Route; editDistributor.Address.Zip = distributor.PostalCode; editDistributor.Address.City = distributor.Locality; editDistributor.IsWholesaler = distributor.IsWholesaler; editDistributor.IsInactive = distributor.IsInactive; editDistributor.Name = distributor.Name; editDistributor.Website = distributor.Website; _dataContext.Entry(editDistributor).State = EntityState.Modified; _dataContext.SaveChanges(); return RedirectToAction("Index"); } return View(distributor);*/ }