public IActionResult GetById(int id) { var result = _computerService.GetById(id); if (result.Success) { return(Ok(result.Data)); } return(BadRequest(result)); }
public HttpResponseMessage Put(HttpRequestMessage request, ComputerViewModel computerVm) { return(CreateHttpResponse(request, () => { HttpResponseMessage errorResponse; if (AddUpdateComputerValidation(request, computerVm, out errorResponse)) { return errorResponse; } var computerDb = _computerService.GetById(computerVm.ComputerId); computerDb.UpdateComputer(computerVm); _computerService.Update(computerDb); _computerService.Save(); var response = request.CreateResponse(HttpStatusCode.OK); return response; })); }