public HttpResponseMessage Post(Governor gov) { if (gov == null) return Request.CreateResponse(HttpStatusCode.NotFound); _rep.Create(gov); var response = Request.CreateResponse(HttpStatusCode.Created, gov); var odataPath = Request.GetODataPath(); if (odataPath == null) { throw new InvalidOperationException("There is no ODataPath in the request."); } var entitySetPathSegment = odataPath.Segments.FirstOrDefault() as EntitySetPathSegment; if (entitySetPathSegment == null) { throw new InvalidOperationException("ODataPath doesn't start with EntitySetPathSegment."); } response.Headers.Location = new Uri(Url.ODataLink(entitySetPathSegment, new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(gov.Id, ODataVersion.V3)))); //response.Headers.Location = new Uri(Url.ODataLink(new EntitySetPathSegment("Governors"), new KeyValuePathSegment(gov.Id.ToString()))); return response; }
public object Create(BLL.Governor o) { var dto = _mapper.Map <BLL.Governor, Governor>(o); _db.AddToGovernors(dto); _db.SaveChanges(); return(o); }
public void Update(BLL.Governor o) { var proxy = o as IDtoProxy; if (proxy != null) { _db.UpdateObject(proxy.Dto); _db.SaveChanges(System.Data.Services.Client.SaveChangesOptions.ReplaceOnUpdate); } }
public void Delete(BLL.Governor o) { var proxy = o as IDtoProxy; if (proxy != null) { _db.DeleteObject(proxy.Dto); _db.SaveChanges(); } }
public int GetIndexOf(BLL.Governor o, FilterParameterCollection filters, SortParameterCollection orderBy) { return(_db.Governors.AddFilters(filters).AddOrders(orderBy).IndexOf(o.Id)); }
public HttpResponseMessage Put([FromODataUri] Guid key, Governor update) { _rep.Update(update); return Request.CreateResponse(HttpStatusCode.NoContent); }