/// <summary> /// Posts a new blog. /// </summary> /// <param name="item">New blog</param> /// <returns>Status message</returns> public async Task<Blog> Post(Blog item) { if (item == null) { throw new HttpResponseException( Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid parameter")); } var blog = await repository.InsertAsync(item); return blog; }
/// <summary> /// Updates an existing blog. /// </summary> /// <param name="key">Blog ID</param> /// <param name="item">Updated blog</param> /// <returns>Status message</returns> public async Task<Blog> Put([FromODataUri] Guid key, Blog item) { if (key == Guid.Empty || item == null) { throw new HttpResponseException( Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid parameter")); } item.ID = key; var blog = await repository.UpdateAsync(item); return blog; }