Пример #1
0
        public IActionResult GetById(int id)
        {
            var result = _computerService.GetById(id);

            if (result.Success)
            {
                return(Ok(result.Data));
            }
            return(BadRequest(result));
        }
Пример #2
0
        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;
            }));
        }