コード例 #1
0
        public string Save(Product aProduct)
        {
            string msg = "";

            if ((aProduct.Code == string.Empty || aProduct.Name == string.Empty || aProduct.Quantity == string.Empty) || !(aProduct.Code.Length == 3) || !(aProduct.Name.Length <= 10 && aProduct.Name.Length >= 5) || IsValidCode(aProduct.Code) || IsValidName(aProduct.Name))
            {
                if (aProduct.Code == string.Empty || aProduct.Name == string.Empty)
                {
                    msg += "Please fill up all product fields\n";
                }

                if (!(aProduct.Code.Length == 3))
                {
                    msg += "Code Length Not valid(Must 3 character)\n";
                }
                if (!(aProduct.Name.Length <= 10 && aProduct.Name.Length >= 5))
                {
                    msg += "Name Length Not valid(Must 5-10 chatacter)\n";
                }
                if (IsValidCode(aProduct.Code))
                {
                    msg += "Code Already exists in Database\n";
                }
                if (IsValidName(aProduct.Name))
                {
                    msg += "Name Already exists in Database\n";
                }
                return(msg);
            }
            //else if (!(aProduct.Code.Length == 3))
            //    {
            //        msg += "Code Length Not valid\n";
            //    }
            //else if (!(aProduct.Name.Length <= 10 && aProduct.Name.Length >= 5))
            //    {
            //        msg += "Name Length Not valid\n";
            //    }

            //else if (IsValidCode(aProduct.Code))
            //     {

            //         msg += "Code Already exists in Database\n";

            //     }
            //else if (IsValidName(aProduct.Name))
            // {
            //     msg += "Name Already exists in Database\n";

            // }
            else
            {
                return(aProductGateWay.Save(aProduct));
            }
        }
コード例 #2
0
 public string Save(Product aProduct)
 {
     if (aProduct.Product_Id == string.Empty || aProduct.Product_Quantity == string.Empty)
     {
         return("Please Fill Up Product Fields");
     }
     else
     {
         if (HsaValidProductId(aProduct.Product_Id))
         {
             int newQuantity = Convert.ToInt32(aProduct.Product_Quantity);
             return(aProductGateWay.SaveUpdatedQuantity(newQuantity, aProduct.Product_Id));
         }
         else
         {
             return(aProductGateWay.Save(aProduct));
         }
     }
 }