コード例 #1
0
 public ActionResult AddProvince(int ? id)
 {
     var model = new ProvinceModel();
     if (id != null)
     {
         model = provinceService.GetProvinceById((int) id).MapFromServerToClient() ?? new ProvinceModel();
     }
     ViewBag.MessageVM = TempData["Message"] as MessageViewModel;
     return View(model);
 }
コード例 #2
0
        public ActionResult AddProvince(ProvinceModel model)
        {
            if (model.ProvinceId == 0)
            {
                model.RecCreatedDate = DateTime.Now;
                model.RecCreatedBy = Session["UserID"].ToString();
            }
            model.RecLastUpdatedBy = Session["UserID"].ToString();
            model.RecLastUpdatedDate = DateTime.Now;

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

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

            return RedirectToAction("AddProvince");
        }