Exemplo n.º 1
0
        /// <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));
        }
Exemplo n.º 2
0
        /// <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));
        }
Exemplo n.º 3
0
        /// <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));
        }
Exemplo n.º 4
0
        /// <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));
        }
Exemplo n.º 5
0
        /// <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));
        }
Exemplo n.º 6
0
        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));
        }