Esempio n. 1
0
        public ActionResult AddArea(long? id)
        {
            AreaViewModel viewModel = new AreaViewModel();
            if (id != null)
            {
                viewModel.Area = areaService.GetAreaById((int)id).MapFromServerToClient();

            }
            viewModel.ProvinceDdl =
                    provinceService.GetAllProvinces().ToList().Select(x => x.MapFromServerToClient()).ToList();
            ViewBag.MessageVM = TempData["Message"] as MessageViewModel;
            return View(viewModel);
        }
Esempio n. 2
0
        public ActionResult AddArea(AreaViewModel model)
        {
            if (model.Area.AreaId == 0)
            {
                model.Area.RecCreatedDate = DateTime.Now;
                model.Area.RecCreatedBy = Session["UserID"].ToString();
            }
            model.Area.RecLastUpdatedBy = Session["UserID"].ToString();
            model.Area.RecLastUpdatedDate = DateTime.Now;

            if (areaService.AddUpdateArea(model.Area.MapFromClientToServer()))
            {
                TempData["Message"] = new MessageViewModel { Message = "Area Added Successfully", IsSaved = true };
            }
            else
            {
                TempData["Message"] = new MessageViewModel { Message = "Something Went wrong", IsError = true };
            }

            if (Request.Form["save"] != null)
                return RedirectToAction("AreaIndex");

            return RedirectToAction("AddArea");
        }