public ActionResult Edit(ServicePointModel market) { Logger.Debug("Inside ServicePoint Controller- Create Http Post"); try { if (Session["OrganizationGUID"] != null) { DropdownValues(); if (ModelState.IsValid) { Market Market = new Market(); Market.MarketGUID = new Guid(market.MarketGUID); Market.IsDefault = true; Market.UserGUID = new Guid(market.UserGUID); Market.EntityType = 0; if (!string.IsNullOrEmpty(market.OrganizationGUID) && market.OrganizationGUID != Guid.Empty.ToString()) { Market.OrganizationGUID = new Guid(market.OrganizationGUID); } else { Market.OrganizationGUID = null; } if (!string.IsNullOrEmpty(market.UserGUID) && market.UserGUID != Guid.Empty.ToString()) { Market.OwnerGUID = new Guid(market.UserGUID); } else { Market.OwnerGUID = null; } Market.MarketName = market.MarketName; if (!string.IsNullOrEmpty(market.UserGUID) && market.UserGUID != Guid.Empty.ToString()) { Market.PrimaryContactGUID = new Guid(market.UserGUID); } else { Market.PrimaryContactGUID = null; } if (!string.IsNullOrEmpty(market.RegionGUID) && market.RegionGUID != Guid.Empty.ToString()) { Market.RegionGUID = new Guid(market.RegionGUID); } else { Market.RegionGUID = null; } if (!string.IsNullOrEmpty(market.TerritoryGUID) && market.TerritoryGUID != Guid.Empty.ToString()) { Market.TerritoryGUID = new Guid(market.TerritoryGUID); } else { Market.TerritoryGUID = null; } Market.FirstName = market.FirstName; Market.LastName = market.LastName; Market.MobilePhone = market.MobilePhone; Market.MarketPhone = market.MarketPhone; Market.HomePhone = market.HomePhone; Market.Emails = market.Emails; Market.AddressLine1 = market.AddressLine1; Market.AddressLine2 = market.AddressLine2; Market.City = market.City; Market.State = market.State; Market.Country = market.Country; Market.ZipCode = market.ZipCode; Market.IsDeleted = false; Market.CreateDate = market.CreateDate; Market.UpdatedDate = DateTime.UtcNow; LatLong latLong = new LatLong(); latLong = GetLatLngCode(Market.AddressLine1, Market.AddressLine2, Market.City, Market.State, Market.Country, Market.ZipCode); Market.TimeZone = getTimeZone(latLong.Latitude, latLong.Longitude).ToString(); Market.Latitude = latLong.Latitude; Market.Longitude = latLong.Longitude; int marketUpdateResult = _IMarketRepository.UpdateMarket(Market); //int marketUpdateResult = _IMarketRepository.Save(); if (marketUpdateResult > 0) { return RedirectToAction("Index"); } } return View(market); } else { return RedirectToAction("SessionTimeOut", "User"); } } catch (Exception ex) { Logger.Error(ex.Message); return View(market); } }
public ActionResult Delete(string id = "") { Logger.Debug("Inside Market Controller- Delete"); try { if (Session["OrganizationGUID"] != null) { ServicePointModel market = new ServicePointModel(); market.MarketGUID = id; _IMarketRepository.DeleteMarket(new Guid(market.MarketGUID)); //_IMarketRepository.Save(); return RedirectToAction("Index"); } else { return RedirectToAction("SessionTimeOut", "User"); } } catch (Exception ex) { Logger.Error(ex.Message); return RedirectToAction("Index"); } }
public ActionResult Edit(string id = "") { Logger.Debug("Inside ServicePoint Controller- Create Http Post"); try { if (Session["OrganizationGUID"] != null) { DropdownValues(); Market EditMarket = _IMarketRepository.GetMarketByID(new Guid(id)); ServicePointModel Market = new ServicePointModel(); if (EditMarket != null) { Market.MarketGUID = EditMarket.MarketGUID.ToString(); Market.IsDefault = Convert.ToBoolean(EditMarket.IsDefault); Market.UserGUID = EditMarket.UserGUID.ToString(); Market.EntityType = Convert.ToInt32(EditMarket.EntityType); Market.OrganizationGUID = EditMarket.OrganizationGUID != null ? EditMarket.OrganizationGUID.ToString() : Guid.Empty.ToString(); Market.OwnerGUID = EditMarket.OwnerGUID != null ? EditMarket.OwnerGUID.ToString() : Guid.Empty.ToString(); Market.MarketName = EditMarket.MarketName; Market.PrimaryContactGUID = EditMarket.PrimaryContactGUID != null ? EditMarket.PrimaryContactGUID.ToString() : Guid.Empty.ToString(); Market.RegionGUID = EditMarket.RegionGUID != null ? EditMarket.RegionGUID.ToString() : Guid.Empty.ToString(); Market.TerritoryGUID = EditMarket.TerritoryGUID != null ? EditMarket.TerritoryGUID.ToString() : Guid.Empty.ToString(); Market.FirstName = EditMarket.FirstName; Market.LastName = EditMarket.LastName; Market.MobilePhone = EditMarket.MobilePhone; Market.MarketPhone = EditMarket.MarketPhone; Market.HomePhone = EditMarket.HomePhone; Market.Emails = EditMarket.Emails; Market.AddressLine1 = EditMarket.AddressLine1; Market.AddressLine2 = EditMarket.AddressLine2; Market.City = EditMarket.City; Market.State = EditMarket.State; Market.Country = EditMarket.Country; Market.ZipCode = EditMarket.ZipCode; Market.CreateDate = Convert.ToDateTime(EditMarket.CreateDate); if (!string.IsNullOrEmpty(Market.RegionGUID)) { var TerritoryDetails = _ITerritoryRepository.GetTerritoryByRegionGUID(new Guid(Market.RegionGUID)).ToList().OrderBy(r => r.Name).Select(r => new SelectListItem { Value = r.TerritoryGUID.ToString(), Text = r.Name }); ViewBag.TerritoryDetails = new SelectList(TerritoryDetails, "Value", "Text"); } return View(Market); } else { return View(); } } else { return RedirectToAction("SessionTimeOut", "User"); } } catch (Exception ex) { Logger.Error(ex.Message); return View(); } }