/// <summary> /// Updates an specific article /// </summary> /// <param name="id">Id of the article</param> /// <param name="value">Updated article</param> public HttpResponseMessage Put(int id, [FromBody] Article element) { var handler = new RepositoryHandler.ArticleHandler(); handler.Update(element); return(Request.CreateResponse(HttpStatusCode.OK)); }
/// <summary> /// Inserts an article to the database /// </summary> /// <param name="value">A new article</param> public HttpResponseMessage Post([FromBody] Article value) { var handler = new RepositoryHandler.ArticleHandler(); handler.Insert(value); return(Request.CreateResponse(HttpStatusCode.OK)); }
/// <summary> /// Returns an specific article /// </summary> /// <param name="id">Id of the article</param> /// <returns>Returns the requested article</returns> public ArticleResponse Get(int id) { var handler = new RepositoryHandler.ArticleHandler(); var entity = handler.GetById(id); return(new ArticleResponse(entity)); }
/// <summary> /// Returns a list of articles /// </summary> /// <returns>Returns all the current articles</returns> public ArticlesResponse Get() { var handler = new RepositoryHandler.ArticleHandler(); var list = handler.List(); return(new ArticlesResponse(list)); }
/// <summary> /// Deletes an specific article /// </summary> /// <param name="id">Id of the article</param> public HttpResponseMessage Delete(int id) { var handler = new RepositoryHandler.ArticleHandler(); handler.Delete(id); return(Request.CreateResponse(HttpStatusCode.OK)); }
public ArticlesResponse GetArticlesByStore(int id) { var handler = new RepositoryHandler.ArticleHandler(); var list = handler.ListByStore(id).Select( r => new Article { Description = r.Description, Id = r.Id, Name = r.Name, Price = r.Price, StoreId = r.StoreId, Total_In_Shelf = r.Total_In_Shelf, Total_In_Vault = r.Total_In_Vault }); return(new ArticlesResponse(list)); }