public int UpdateItem(ItemsModel model, int id)
        {
            try
            {
                var list = (from Items in dbContext.ScItems
                            where Items.Description == model.Description && Items.ItemCategoryId == model.ItemCategoryId && Items.ItemId != id
                            select Items).Count();
                if (list == 0)
                {
                    ScItems item = new ScItems();

                    item.ItemId         = model.ItemId;
                    item.ItemCategoryId = model.ItemCategoryId;
                    item.Description    = model.Description;
                    item.Price          = model.Price;
                    item.DisplayOrder   = model.DisplayOrder;
                    item.IsInOffer      = model.IsInOffer;
                    item.OfferValidFrom = model.OfferValidFrom;
                    item.OfferValidTo   = model.OfferValidTo;
                    item.OfferPrice     = model.OfferPrice;

                    dbContext.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    dbContext.SaveChanges();
                    return(1);
                }
                else
                {
                    return(-1);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
        public int AddToCart(CartModel model)
        {
            try
            {
                var item = (from cart in dbContext.ScUserCart
                            where cart.UserId == model.UserId && cart.ItemId == model.ItemId
                            select cart).FirstOrDefault();
                if (item != null)
                {
                    ScUserCart userCart = dbContext.ScUserCart.Find(item.UserCartId);

                    userCart.UserCartId = userCart.UserCartId;
                    userCart.UserId     = model.UserId;
                    userCart.ItemId     = model.ItemId;
                    userCart.Quantity   = item.Quantity + model.Quantity;

                    dbContext.Entry(userCart).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    dbContext.SaveChanges();

                    model.UserCartId = userCart.UserCartId;
                }
                else
                {
                    ScUserCart newCart = new ScUserCart();
                    newCart.UserId   = model.UserId;
                    newCart.ItemId   = model.ItemId;
                    newCart.Quantity = model.Quantity;
                    dbContext.Add(newCart);
                    dbContext.SaveChanges();
                    model.UserCartId = newCart.UserCartId;
                }
                return(model.UserCartId);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }