public ActionResult <ItemResponse <int> > Update(AdvertiserUpdateRequest model) { int code = 200; BaseResponse response = null; try { _service.Update(model); response = new SuccessResponse(); } catch (Exception ex) { code = 500; response = new ErrorResponse(ex.Message); } return(StatusCode(code, response)); }
public IActionResult SaveEntity(AdvertiserViewModel advertiserVm) { if (!ModelState.IsValid) { IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); return(new BadRequestObjectResult(allErrors)); } else { if (advertiserVm.KeyId == 0) { _advertiserService.Add(advertiserVm); } else { _advertiserService.Update(advertiserVm); } _advertiserService.Save(); return(new OkObjectResult(advertiserVm)); } }