public IActionResult Update([FromForm] RaitingBooksViewModel model) { try { if (ModelState.IsValid) { var result = _raitingBooksService.Update(model, this.CurrentUser()); if (result != null) { return(Ok("Оценка успешно изменена")); } else { throw new Exception("При изменении оценки произошла ошибка"); } } else { throw new Exception("Данные заполнены не верно"); } } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public RaitingBooksModel Update(RaitingBooksViewModel model, string userId) { if (model != null && userId != null) { RaitingBooksModel updateModel = model; updateModel.UserId = userId; var result = _raitingBooksRepository.UpdateRaiting(updateModel); return(result); } else { throw new Exception("Данный заполенны не полностью"); } }
public RaitingBooksModel Create(RaitingBooksViewModel model, string userId) { if (model != null && userId != null) { RaitingBooksModel createModel = model; createModel.UserId = userId; var result = _raitingBooksRepository.Create(createModel); return(result); } else { throw new Exception("Данные заполнены не полностью"); } }