示例#1
0
        public ActionResult Create(WardViewModel model)
        {
            if (ModelState.IsValid)
            {
                var Ward = new Ward();
                AutoMapper.Mapper.Map(model, Ward);
                SetModifier(Ward);
                WardService.Create(Ward);
                Ward.WardId = Ward.Id.ToString();
                WardService.Update(Ward);

                TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
                if (Request["IsPopup"] != null && Request["IsPopup"].ToString().ToLower().Equals("true"))
                {
                    return(RedirectToAction("_ClosePopup", "Home", new { area = "", FunctionCallback = "updateWard(" + Ward.Id + ", '" + Helpers.Common.Capitalize(string.Format("{0} {1}", Ward.Type, Ward.Name)) + "')" }));
                }
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
示例#2
0
 public ActionResult DeleteWard(int id)
 {
     try
     {
         //find item
         var item = _wardService.SelectById(id);
         if (item != null && item.IsDelete == false)
         {
             item.IsDelete = true;
             _wardService.Update(item);
             return(Content("Remove success"));
         }
         else
         {
             return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, "Dữ liệu cần xóa không tồn tại"));
         }
     }
     catch (Exception ex)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Server Error"));
     }
 }
示例#3
0
        public IActionResult SaveEntity(WardViewModel wardVm)
        {
            if (!ModelState.IsValid)
            {
                IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(new BadRequestObjectResult(allErrors));
            }

            if (wardVm.Id == 0)
            {
                _wardService.Add(wardVm);
            }
            else
            {
                _wardService.Update(wardVm);
            }

            _wardService.Save();
            return(new OkObjectResult(wardVm));
        }
        public async Task <ActionResult <WardDetail_WardDTO> > Update([FromBody] WardDetail_WardDTO WardDetail_WardDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            Ward Ward = ConvertDTOToEntity(WardDetail_WardDTO);

            Ward = await WardService.Update(Ward);

            WardDetail_WardDTO = new WardDetail_WardDTO(Ward);
            if (Ward.IsValidated)
            {
                return(WardDetail_WardDTO);
            }
            else
            {
                return(BadRequest(WardDetail_WardDTO));
            }
        }
示例#5
0
        public async Task <ResponseModel> Update([FromBody] WardModel model)
        {
            var response = await _wardService.Update(model);

            return(response);
        }