public ActionResult CreateEdit(UUnitOfMeasure unitOfMeasure, string Action) { if (ModelState.IsValid) { if (Action.Equals("Edit")) { unitOfMeasure._UnitOfMeasure.CountryProgrammeId = countryProg.Id; if (unitOfMeasureService.EditUnitOfMeasure(unitOfMeasure._UnitOfMeasure)) { unitOfMeasure = new UUnitOfMeasure(); ModelState.Clear(); } } else { unitOfMeasure._UnitOfMeasure.CountryProgrammeId = countryProg.Id; if (unitOfMeasureService.AddUnitOfMeasure(unitOfMeasure._UnitOfMeasure)) { unitOfMeasure = new UUnitOfMeasure(); ModelState.Clear(); } } } return(ListView()); }
public async Task <IActionResult> EditUnitOfMeasure([FromBody] UnitOfMeasureEditViewModel viewModel) { if (viewModel == null) { return(this.ApiResponse <string>(null, "Empty payload", ApiResponseCodes.INVALID_REQUEST)); } var result = await _unitOfMeasureService.EditUnitOfMeasure(viewModel, this.CurrentUser.UserId); if (result.Any()) { return(base.ApiResponse <string>(null, result.Select(r => r.ErrorMessage).ToArray(), ApiResponseCodes.INVALID_REQUEST, result.Count())); } return(this.ApiResponse <UnitOfMeasureEditViewModel>(viewModel, "successful.", ApiResponseCodes.OK)); }