public HttpResponseMessage Post(HttpRequestMessage request, Category category) { var modelCategory = new Data.Model.Category { Description = category.Description, Name = category.Name }; _session.Save(modelCategory); var newCategory = _categoryMapper.CreateCategory(modelCategory); var href = newCategory.Links.First(x => x.Rel == "self").Href; var response = request.CreateResponse(HttpStatusCode.Created, newCategory); response.Headers.Add("Location", href); return response; }
public Category Put(long id, Category category) { var modelCateogry = _categoryFetcher.GetCategory(id); modelCateogry.Name = category.Name; modelCateogry.Description = category.Description; _session.SaveOrUpdate(modelCateogry); return _categoryMapper.CreateCategory(modelCateogry); }