Example #1
0
 public void Create([FromBody] ProductVO Product)
 {
     if (ModelState.IsValid)
     {
         da.AddProduct(Mapper.Map <Models.Product>(Product));
     }
 }
Example #2
0
 public int AddNewProduct(ProductBO objProductBL)
 {
     try
     {
         return(objProductDA.AddProduct(objProductBL));
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #3
0
        public long AddProduct(ProductModel model)       //Add Product
        {
            var entity = _mapper.Map <ProductModel, Product>(model);

            entity.ProductStatus         = "Pending";
            entity.ProductQuantityInKart = 0;
            entity.ProductTrend          = "False";

            var id = obj.AddProduct(entity);

            return(id);
        }
        public Boolean AddProduct(ProductModel model)       //Add Product
        {
            var entity = _mapper.Map <ProductModel, Product>(model);

            entity.ProductStatus         = "Pending";
            entity.ProductQuantityInKart = 0;
            entity.ProductTrend          = "False";

            if (obj.AddProduct(entity))
            {
                return(true);
            }
            return(false);
        }
Example #5
0
        public IActionResult AddProduct(Product product)
        {
            product.creationDate = DateTime.Today.Date;
            var res = _pro.AddProduct(product);

            if (res)
            {
                return(Ok(new { message = "Product added successfully" }));
            }
            else
            {
                return(BadRequest(new { message = "Error, can't add product" }));
            }
        }
Example #6
0
        public HttpResponseMessage Post(Product newProduct)
        {
            try
            {
                if (newProduct == null)
                {
                    throw new HttpResponseException(AddRequest(HttpStatusCode.BadRequest, "parameter is empty"));
                }

                ClaimsPrincipal p  = RequestContext.Principal as ClaimsPrincipal;
                int             id = ProductDA.AddProduct(newProduct, p.Claims);

                HttpResponseMessage response = new HttpResponseMessage();
                string url = string.Format("{0}{1}", HttpContext.Current.Request.Url.ToString(), id);
                response.Headers.Location = new Uri(url);
                response.StatusCode       = HttpStatusCode.Created;
                return(response);
            }
            catch
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }