public ActionResult Edit(MunicipalityModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.UpdatedDate = DateTime.Now;

                    munService.Update(model);

                    TempData["Success"] = $"{model.MunicipalityName} is updated!!";

                    return(RedirectToAction("Index"));
                }

                TempData["Danger"] = "Something went wrong Form error";
            }
            catch (Exception e)
            {
                TempData["Danger"] = $"Oppppsss something went wrong {e.Message}";
            }

            model.MunicipalityTypeList = dynamicList.GetMunicipalityTypeList();

            model.DistrictList = dynamicList.GetDistrictSelectList();

            return(View(@"~\Views\Configuration\Municipality\Edit.cshtml", model));
        }
Esempio n. 2
0
        public static Municipality MuncipalityModelToMunicpality(MunicipalityModel model)
        {
            var muncipality = new Municipality
            {
                Id               = model.Id,
                CreatedDate      = model.CreatedDate,
                DisId            = model.DisId,
                MunicipalityName = model.MunicipalityName,
                MuniTypeId       = model.MuniTypeId,
                UpdatedDate      = model.UpdatedDate
            };

            return(muncipality);
        }
Esempio n. 3
0
        public static MunicipalityModel MuncipalityToMuncipalityModel(Municipality model)
        {
            var muncipalityModel = new MunicipalityModel
            {
                Id         = model.Id,
                MuniTypeId = model.MuniTypeId,
                MunType    = new MuncipalityTypeModel
                {
                    MuniType = model.MunicipalityType != null ? model.MunicipalityType.MuniType : "",
                },
                DisId    = model.DisId,
                District = new DistrictModel
                {
                    DistrictNameEng = model.District != null ? model.District.DistrictNameEng : ""
                },
                MunicipalityName = model.MunicipalityName,
                CreatedDate      = model.CreatedDate,
                UpdatedDate      = model.UpdatedDate
            };

            return(muncipalityModel);
        }
Esempio n. 4
0
        public void Update(MunicipalityModel model)
        {
            var municipality = Mapper.MuncipalityMapper.MuncipalityModelToMunicpality(model);

            unitOfWork.MunicipalityRepository.Update(municipality);
        }