Esempio n. 1
0
        private void Create(Product product)
        {
            ProductBusiness productBusiness = new ProductBusiness();
            int             productId       = productBusiness.Create(product);

            MessageBox.Show($"Produto ID {productId} cadastrado com sucesso!", "Sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 2
0
        public HttpResponseMessage Post([FromBody] Product product)
        {
            HttpResponseMessage msg = null;

            var oBus = new ProductBusiness();

            try
            {
                //Verificar antes de incluir
                var productTest = oBus.Get(product.sku);
                if (productTest != null)
                {
                    msg = Request.CreateResponse(HttpStatusCode.BadRequest, "Product exists");
                }
                else
                {
                    oBus.Create(product);
                    msg = Request.CreateResponse(HttpStatusCode.OK);
                }
            }
            catch (Exception ex)
            {
                msg = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }
            finally
            {
                oBus = null;
            }

            return(msg);
        }
 public IHttpActionResult Create(Product product)
 {
     if (product == null)
     {
         return(BadRequest());
     }
     return(Ok(_ProductBusiness.Create(product)));
 }
 public Product Add(Product product)
 {
     try
     {
         var bc = new ProductBusiness();
         return(bc.Create(product));
     }
     catch (Exception ex)
     {
         var httpError = new HttpResponseMessage()
         {
             StatusCode   = (HttpStatusCode)422,
             ReasonPhrase = ex.Message
         };
         throw new HttpResponseException(httpError);
     }
 }
Esempio n. 5
0
 public Product Add(Product product)
 {
     try
     {
         var bc = new ProductBusiness();
         return(bc.Create(product));
     }
     catch (Exception ex)
     {
         var httpError = new HttpResponseMessage()
         {
             StatusCode = (HttpStatusCode)422,
             Content    = new StringContent(ex.Message + "+" + ex.InnerException),
         };
         throw new HttpResponseException(httpError);
     }
 }
        private void btnkayit_Click(object sender, EventArgs e)
        {
            Product p = new Product
            {
                BarcodeNo       = txtbarkodno.Text,
                ProductName     = txturunad.Text,
                ProductPicture  = txtresimurl.Text,
                Brand           = txtmarka.Text,
                Price           = txturunfiyat.Text,
                ExpirationDate  = txtdatetime.Text,
                ProductionPlace = txturetimyeri.Text,
                Contents        = txticindekiler.Text,
                Weights         = txtagirlik.Text,
                Stock           = Convert.ToInt32(txtstok.Text),
                CategoryName    = txtkategori.Text,
            };

            pb.Create(p);
            ListProducts();
            MessageBox.Show("Ürün Kayıt İşlemi Başarıyla Tamamlandı", "Ürün Kayıdı Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
            txturunad.Clear(); txtbarkodno.Clear(); txtid.Clear(); txtresimurl.Clear(); txtmarka.Clear();
            txturunfiyat.Clear(); txturetimyeri.Clear(); txticindekiler.Clear(); txtagirlik.Clear(); txtstok.Clear(); txturunad.Focus();
        }
Esempio n. 7
0
 private void AddProductButton_OnClick(object sender, RoutedEventArgs e)
 {
     if (_viewModel.Product.Provider != null && string.IsNullOrWhiteSpace(_viewModel.Product.error))
     {
         Notification.Text = "";
         if (_viewModel.Product.Id != 0)
         {
             productBusiness.Update(_viewModel.Product);
             ChangesLog changesLog = new ChangesLog()
             {
                 Date        = DateTime.Now,
                 Description = "Actualizacion de Producto",
                 Module      = "Producto",
                 User        = LogInfo.LoggedUser
             };
             changesLogBusiness.Create(changesLog);
         }
         else
         {
             productBusiness.Create(_viewModel.Product);
             ChangesLog changesLog = new ChangesLog()
             {
                 Date        = DateTime.Now,
                 Description = "Creacion de nuevo Producto",
                 Module      = "Producto",
                 User        = LogInfo.LoggedUser
             };
             changesLogBusiness.Create(changesLog);
         }
         OnAddProductClicked();
     }
     else
     {
         Notification.Text =
             "Producto no ha sido registrado, favor de ingresar los datos correspondientes";
     }
 }
Esempio n. 8
0
 public Product Create(Product product)
 {
     return(business.Create(product));
 }