Example #1
0
        public HttpResponseMessage Put(HttpRequestMessage request, WarrantyViewModel warrantyVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var warrantyDb = _warrantyService.GetByID(warrantyVm.ID);
                    warrantyDb.UpdateWarranty(warrantyVm);
                    _warrantyService.Update(warrantyDb);
                    _warrantyService.SaveChanges();

                    response = request.CreateResponse(HttpStatusCode.OK);
                }
                return response;
            }));
        }