public async Task <IHttpActionResult> Put(int domainId, [FromBody] ProviderDomainUpdateBindingModel model) { if (ModelState.IsValid) { OperationResult <ServiceDomainInfo> result = await DomainsManager.UpdateAsync(domainId, model, UserId); if (result.Success) { var newComer = Mapper.Map <ServiceDomainViewModel>(result.Data); return(Ok(newComer)); } else { return(BadRequest(result.ErrorMessage)); } } else { return(BadRequest("Некорректные данные. Сохранение невозможно.")); } }
public async Task <OperationResult <ServiceDomainInfo> > UpdateAsync(int domainId, ProviderDomainUpdateBindingModel model, int UserId) { var domain = await Repo.FindByIdAsync(domainId); domain.QA.Stars = model.Stars; domain.QA.Comment = model.Comment; try { await Repo.SaveAsUserAsync(UserId); } catch (Exception ex) { return(OperationResult <ServiceDomainInfo> .Error(ex.Message)); } Repo.BindGrades(domain); var graph = await Repo.GetGraphs(x => x.Id == domainId).FirstAsync(); return(OperationResult <ServiceDomainInfo> .Ok(graph)); }