Example #1
0
        public IActionResult ChangeQuantity(int sellerId, int productTypeId, bool isAdd, short number = 0)
        {
            if (loginPersistence.PersistLogin() == null)
            {
                return(Json("Not login"));
            }

            try
            {
                ICollection <string> errors;
                if (isAdd)
                {
                    eCommerce.AddProductQuantityThroughAdmin(sellerId, productTypeId, number, out errors);
                }
                else
                {
                    eCommerce.ReduceProductQuantityThroughAdmin(sellerId, productTypeId, number, out errors);
                }

                if (errors.Any())
                {
                    string errorString = "";
                    foreach (string error in errors)
                    {
                        errorString += error + "\n";
                    }
                    errorString.Remove(errorString.Length - 1);
                    return(Json(errorString));
                }
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            return(Json(""));
        }