public HttpResponseMessage Post(TimeSheet timesheet) { timesheet.ID = RandomString(10); //_repository.Insert(timesheet); _repository.Add(timesheet); string uri = Url.Route(null, new { id = timesheet.ID }); // Where is the new timesheet? var response = Request.CreateResponse(HttpStatusCode.Created, timesheet); response.Headers.Location = new Uri(Request.RequestUri, uri); return response; }
public HttpResponseMessage Put(TimeSheet timesheet) { var response = Request.CreateResponse(HttpStatusCode.OK, timesheet); //_repository.Save(timesheet); if (_repository.Where(p => p.ID == timesheet.ID).Any()) { int index = _repository.FindIndex(p => p.ID == timesheet.ID); _repository[index] = timesheet; } else { string gg = ""; } string uri = Url.Route(null, new { id = timesheet.ID }); // Where is the modified timesheet? response.Headers.Location = new Uri(Request.RequestUri, uri); return response; }