public HttpResponseMessage Put(int id, [FromBody] RentJournal item) { try { var i = db.RentJournalSet.Find(id); if (i == null) { return(Request.CreateResponse(HttpStatusCode.NotModified, "Item is not found")); } i.ClientId = item.ClientId; i.WaterId = item.WaterId; i.PayMethodId = item.PayMethodId; i.WaterCraftId = item.WaterCraftId; i.InstructionTypeId = item.InstructionTypeId; i.InstructorId = item.InstructorId; i.Date = item.Date; i.Cost = item.Cost; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Post([FromBody] RentJournal value) { try { db.RentJournalSet.Add(value); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }