public int Add(BrandModel model)
        {
            var brand = new Brand
            {
                Name = model.Name
            };

            db.Brands.Add(brand);
            return(db.SaveChanges());
        }
        public int Add(CouponModel model)
        {
            var coupon = new Coupon
            {
                CouponCode = model.CouponCode,
                Discount   = model.Discount
            };

            db.Coupons.Add(coupon);
            return(db.SaveChanges());
        }
Exemple #3
0
        public int Add(DealModel model)
        {
            var deal = new Deal
            {
                Title  = model.Title,
                Image  = model.DealImage,
                Active = model.Active
            };

            db.Deals.Add(deal);
            return(db.SaveChanges());
        }
Exemple #4
0
        public int Add(ProductModel model)
        {
            var product = new Product
            {
                Name          = model.Name,
                Price         = model.Price,
                Description   = model.Description,
                Image         = model.ProductImage,
                BrandId       = model.BrandId,
                Active        = model.Active,
                IsAccessories = model.IsAccessories
            };

            db.Products.Add(product);
            return(db.SaveChanges());
        }
        public int Add(CartModel model)
        {
            var order = new Order
            {
                ProductId     = model.ProductId,
                Amount        = model.Price,
                Quantity      = model.Quantity,
                OrderStatusId = 1,
                OrderOn       = DateTime.Now,
                UserId        = Convert.ToInt32(System.Web.HttpContext.Current.Session["UserId"])
            };

            if (model.CouponApplied)
            {
                order.CouponApplied = model.CouponApplied;
                order.CouponId      = model.CouponId;
            }

            var payment = new Payment
            {
                CardNo        = model.Payment.CardNo,
                ExpiryMonth   = model.Payment.ExpiryMonth,
                ExpiryYear    = model.Payment.ExpiryYear,
                CVV           = model.Payment.CVV,
                PaidOn        = DateTime.Now,
                PaymentStatus = "Success"
            };

            order.Payments.Add(payment);

            var address = new ShippingAddress
            {
                Name    = model.ShippingAddress.Name,
                Mobile  = model.ShippingAddress.Mobile,
                Address = model.ShippingAddress.Address,
                City    = model.ShippingAddress.City,
                ZipCode = model.ShippingAddress.ZipCode
            };

            order.ShippingAddresses.Add(address);

            db.Orders.Add(order);
            return(db.SaveChanges());
        }
        public int Update(UserModel model)
        {
            var user = db.Users.FirstOrDefault(m => m.UserId == model.UserId);

            if (user != null)
            {
                user.Name     = model.Name;
                user.Email    = model.Email;
                user.Mobile   = model.Mobile;
                user.UserName = model.UserName;
                user.Active   = model.Active;
                return(db.SaveChanges());
            }

            return(0);
        }