public ActionResult AddLocation(LocationViewModel model) { if (model.Location.LocationId == 0) { model.Location.RecCreatedDate = DateTime.Now; model.Location.RecCreatedBy = Session["UserID"].ToString(); } model.Location.RecLastUpdatedBy = Session["UserID"].ToString(); model.Location.RecLastUpdatedDate = DateTime.Now; var savedLocationId = locationService.AddUpdateLocations(model.Location.MapFromClientToServer()); if (savedLocationId > 0) { TempData["Message"] = new MessageViewModel { Message = "Location Added Successfully", IsSaved = true }; if (!AddLocationImages(savedLocationId)) { TempData["Message"] = new MessageViewModel { Message = "Location Added, But Images not saved. All Images Must be less than 1Mb", IsSaved = true }; } } else { TempData["Message"] = new MessageViewModel { Message = "Something Went wrong", IsError = true }; } if (Request.Form["save"] != null) return RedirectToAction("LocationIndex"); return RedirectToAction("AddLocation"); }
public ActionResult AddLocation(long? id) { LocationViewModel viewModel = new LocationViewModel(); if (id != null) { viewModel.Location = locationService.GetLocationById((int)id).MapFromServerToClient(); } viewModel.ProvinceDdl = provinceService.GetAllProvinces().ToList().Select(x => x.MapFromServerToClient()).ToList(); viewModel.AreaDdl = areaService.GetAllAreas().ToList().Select(x => x.MapFromServerToClient()).ToList(); viewModel.CategoryDdl = categoryService.GetAllCategories().ToList().Select(x => x.MapFromServerToClient()).ToList(); ViewBag.MessageVM = TempData["Message"] as MessageViewModel; return View(viewModel); }