public ActionResult Create(MunicipalityModel model) { try { if (ModelState.IsValid) { model.CreatedDate = DateTime.Now; munService.Add(model); TempData["Success"] = $"{model.MunicipalityName} added !!"; return(RedirectToAction("Index")); } TempData["Danger"] = "Form Error"; } catch (Exception e) { TempData["Danger"] = $"Something went wrong {e.Message}"; } model.DistrictList = dynamicList.GetDistrictSelectList(); model.MunicipalityTypeList = dynamicList.GetMunicipalityTypeList(); return(View(@"~\Views\Configuration\Municipality\Create.cshtml", model)); }
public async Task <IActionResult> Create([Bind("MunicipalityId,Name,IsActive")] Municipality municipality) { if (ModelState.IsValid) { await _service.Add(municipality); return(RedirectToAction(nameof(Index))); } return(View(municipality)); }
public IActionResult Create(CreateMunicipalityDto createMunicipalityDto) { var municipality = _municipalityService.Add(createMunicipalityDto); return(CreatedAtAction(nameof(Get), new { id = municipality.Id }, municipality)); }