Exemple #1
0
        public IHttpActionResult postProduct([FromBody] ProductDA product)
        {
            ProductBA pm   = new ProductBA();
            ProductDA data = pm.addProduct(product);

            return(Ok("Product was created successfully"));
        }
Exemple #2
0
        public IHttpActionResult Delete(int id)
        {
            ProductBA pm = new ProductBA();

            pm.deleteProduct(id);

            return(Ok("Product was deleted successfully"));
        }
Exemple #3
0
        public IHttpActionResult Put(string id, [FromBody] ProductDA product)
        {
            ProductBA pm   = new ProductBA();
            ProductDA data = pm.changeProduct(id, product);

            if (data.Id == null)
            {
                return(BadRequest("Product wasn't changed"));
            }
            return(Ok(data));
        }
Exemple #4
0
        public IHttpActionResult Get()
        {
            ProductBA pm = new ProductBA();
            IEnumerable <ProductDA> data = pm.findAll();

            if (data.Count() < 1)
            {
                // return BadRequest("Products weren't found");
            }

            return(Ok(data));
        }
Exemple #5
0
        public IHttpActionResult Get(int id)
        {
            ProductBA pm   = new ProductBA();
            ProductDA data = pm.findProduct(id);

            if (data.Id == null)
            {
                //return BadRequest("Product wasn't found");

                IHttpActionResult response;
                response = ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Product with id: " + id + " does't exist"));
                return(response);
            }

            return(Ok(data));
        }
Exemple #6
0
        public override void BuilderPartA()
        {
            Product product = new ProductBA();

            if (this.product == null)
            {
                this.product = product;
            }
            else
            {
                Product actual = this.product;
                //while (actual.GetNextProduct() != null)
                //{
                //    actual = actual.GetNextProduct();
                //}
                actual.Link(this.product);
            }
        }