Exemplo n.º 1
0
        public ActionResult Edit(ProvinceEditModel model)
        {
            if (ModelState.IsValid)
            {
                short sysMessageId     = 0;
                byte  sysMessageTypeId = 0;
                model.SystemStatus = SystemStatus.Error;
                var province = new Provinces
                {
                    CountryId    = model.CountryId,
                    ProvinceId   = model.ProvinceId,
                    ProvinceName = model.ProvinceName,
                    ProvinceDesc = model.ProvinceDesc,
                    DisplayOrder = model.DisplayOrder,
                    CrUserId     = model.CrUserId,
                    CrDateTime   = model.CrDateTime
                };
                sysMessageTypeId = model.CountryId > 0 ? province.Update(0, _userId, ref sysMessageId) : province.Insert(0, _userId, ref sysMessageId);

                if (sysMessageId > 0)
                {
                    var sysMessage = new SystemMessages().Get(sysMessageId);
                    if (sysMessageTypeId == CmsConstants.SystemMessageIdSuccess)
                    {
                        model.SystemStatus = SystemStatus.Success;
                    }
                    ModelState.AddModelError("SystemMessages", sysMessage.SystemMessageDesc);
                }
                else
                {
                    ModelState.AddModelError("SystemMessages", "Bạn vui lòng thử lại sau.");
                }
            }
            return(View(model));
        }