Example #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));
        }
        public async Task <ActionResult <WardDetail_WardDTO> > Create([FromBody] WardDetail_WardDTO WardDetail_WardDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            Ward Ward = ConvertDTOToEntity(WardDetail_WardDTO);

            Ward = await WardService.Create(Ward);

            WardDetail_WardDTO = new WardDetail_WardDTO(Ward);
            if (Ward.IsValidated)
            {
                return(WardDetail_WardDTO);
            }
            else
            {
                return(BadRequest(WardDetail_WardDTO));
            }
        }