Esempio n. 1
0
 public Notify Create(POS_PRODUCT ProductModel)
 {
     try
     {
         objNotify.RowEffected = _objDALProduct.CreateProduct(ProductModel);
         if (objNotify.RowEffected > 0)
         {
             objNotify.NotifyMessage = "Record Created Successfully";
         }
         else
         {
             objNotify.NotifyMessage = "Product Not Created";
         }
         return(objNotify);
     }
     catch (Exception ex)
     {
         if (ex is DALException)
         {
             throw ex;
         }
         else
         {
             ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
         }
         throw new BALException(ex.Message.ToString());
     }
 }
Esempio n. 2
0
        public static int CreateProduct(String productName, ref List <string> errors)
        {
            List <ProductInfo> pi = DALProduct.ReadProductList(ref errors);

            if (productName == null)
            {
                errors.Add("Product name cannot be null");
                return(-1);
            }

            for (int i = 0; i < pi.Count; i++)
            {
                if (productName.ToLower() == pi[i].product_name.ToLower())
                {
                    errors.Add("Product name already exists");
                }
            }

            if (errors.Count > 0)
            {
                return(-1);
            }

            return(DALProduct.CreateProduct(productName, ref errors));
        }
Esempio n. 3
0
        public void CreateProductTest()
        {
            Random        rand           = new Random();
            string        product_name   = "Hello Kitty" + rand.Next(10000); // TODO: Initialize to an appropriate value
            List <string> errors         = new List <string>();              // TODO: Initialize to an appropriate value
            List <string> errorsExpected = new List <string>();              // TODO: Initialize to an appropriate value

            int actual;

            actual = DALProduct.CreateProduct(product_name, ref errors);
            ProductInfo pi = DALProduct.ReadProductDetail(actual, ref errors);

            Assert.AreEqual(pi.product_name, product_name);
            Assert.AreEqual(pi.product_id, actual);
        }