public HttpResponseMessage RenameCategory(Category item) { item = repository.RenameCategory(item); var response = Request.CreateResponse<Category>(HttpStatusCode.Created, item); string uri = Url.Link("DefaultApi", new { id = item.Id }); response.Headers.Location = new Uri(uri); return response; }
public Category AddCategory(Category item) { db.Categories.Add(item); db.SaveChanges(); return item; }
public Category RenameCategory(Category item) { Category category = db.Categories.SingleOrDefault(c => c.Id == item.Id); category.Name = item.Name; db.SaveChanges(); return item; }