public async Task <ActionResult> Edit([Bind(Include = "Id,Name,FlagPhotoUrl, CountryId")] StateEditViewModel state, HttpPostedFileBase binaryFile) { if (!ModelState.IsValid) { return(View(state)); } if (binaryFile != null) { state.FlagPhotoUrl = await UploadPhotoAsync(binaryFile, ContainerName.StateFlag); } await Put($"{UrlBase}/{state.Id}", JsonConvert.SerializeObject(state)); return(RedirectToAction("Index")); }
public IActionResult Edit(int id) { ViewBag.Allcountry = _CountryRegistrationservices.GetAllCountry(); var objcountry = _StateRegistrationService.GetById(id); if (objcountry == null) { return(NotFound()); } var model = new StateEditViewModel { id = objcountry.id, countryid = objcountry.countryid, StateName = objcountry.StateName }; return(View(model)); }
public async Task <IActionResult> Edit(StateEditViewModel model) { if (ModelState.IsValid) { var objcountry = _StateRegistrationService.GetById(model.id); if (objcountry == null) { return(NotFound()); } objcountry.id = model.id; objcountry.countryid = model.countryid; objcountry.StateName = model.StateName; await _StateRegistrationService.UpdateAsync(objcountry); return(RedirectToAction(nameof(Index))); } else { return(View()); } }