Example #1
0
        public bool delete(int id)
        {
            try
            {
                var Purchasing = context.Purchasings.Find(id);

                bool quantityCheck = util.checkingQuantitySingleProduct(Purchasing.modelId, Purchasing.Quantity, Purchasing.store_id);
                if (quantityCheck == false)
                {
                    return(false);
                }
                bool res = util.updateSingleQuantity(Purchasing.modelId, Purchasing.Quantity, Purchasing.store_id, "Subtract");
                if (res == false)
                {
                    return(false);
                }
                Purchasing c = new Purchasing()
                {
                    purchase_id = id
                };

                context.Entry(c).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
                context.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        public bool AddStockManually(StockViewModel model)
        {
            bool res = false;

            switch (model.option)
            {
            case "Add":
                res = util.updateSingleQuantity(model.modelId, model.Quantity, model.store_id, "Add");
                break;

            case "Subtract":
                res = util.checkingQuantitySingleProduct(model.modelId, model.Quantity, model.store_id);
                if (!res)
                {
                    break;
                }
                res = util.updateSingleQuantity(model.modelId, model.Quantity, model.store_id, "Subtract");
                break;

            default:
                res = false;
                break;
            }
            return(res);
        }