Пример #1
0
 public AccountController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IMailer mailer, CookieServices cookieServices, DoAnTMDT_Entities context)
 {
     _signInManager  = signInManager;
     _userManager    = userManager;
     _mailer         = mailer;
     _cookieServices = cookieServices;
     _context        = context;
 }
Пример #2
0
 public HomeController(CookieServices cookieServices, DoAnTMDT_Entities context, IConfiguration config, UserManager <ApplicationUser> userManager)
 {
     _cookieServices = cookieServices;
     _userManager    = userManager;
     _context        = context;
     _clientID       = config["paypal:clientId"];
     _secretID       = config["paypal:clientSecret"];
 }
Пример #3
0
 public HomeController(CookieServices _ICookieServices,
                       SessionUser _SessionUser,
                       SessionServices _SessionServices)
 {
     CookiesServices = _ICookieServices;
     SessionUser     = _SessionUser;
     SessionServices = _SessionServices;
 }
Пример #4
0
        public ProvidersConsultController(CookieServices _ICookieServices,
                                          SessionUser _SessionUser,
                                          IConfiguration _IConfiguration)
        {
            CookiesServices = _ICookieServices;
            SessionUser     = _SessionUser;
            Configuration   = _IConfiguration;

            DataBaseSettings    = Configuration.GetSectionMapped <DataBaseSettings>();
            ApiServicesSettings = Configuration.GetSectionMapped <ApiServicesSettings>();
        }
Пример #5
0
 public DisplayCartTotalViewComponent(CookieServices cookieServices, DoAnTMDT_Entities context)
 {
     _cookieServices = cookieServices;
     _context        = context;
 }
Пример #6
0
 // Dependency injection
 public SessionUser(CookieServices _CookieServices,
                    SessionServices _SessionServices)
 {
     CookieServices  = _CookieServices;
     SessionServices = _SessionServices;
 }
Пример #7
0
        internal static IEnumerable <Cart> DisplayCompletedCart(this DoAnTMDT_Entities _context, HttpContext httpContext, CookieServices _cookieServices)
        {
            string cookie = _cookieServices.ReadCookie(httpContext, "CART_INFORMATION");

            if (cookie != null)
            {
                var dsdonhangdathanhtoan = _context.CartTable.Include(x => x.CartDetails).ThenInclude(x => x.Product).Where(x => x.IsCompleted && !x.IsDisplay).ToList();
                return(dsdonhangdathanhtoan);
            }
            return(null);
        }
Пример #8
0
        internal static IEnumerable <Cart> DisplayCart(this DoAnTMDT_Entities _context, HttpContext httpContext, CookieServices _cookieServices)
        {
            string cookie = _cookieServices.ReadCookie(httpContext, "CART_INFORMATION");

            if (cookie != null)
            {
                //_cookieServices.AddCookie(httpContext, "CART_INFORMATION", httpContext.User.FindFirstValue(ClaimTypes.NameIdentifier));
                //Muốn lấy đơn hàng theo điều kiện thì dùng exstension method Where(x => x.Property) ở đoạn code dưới
                //Code dưới hiển thị danh sách chưa đơn hàng chưa được thanh toán
                var dsdonhangchuathanhtoan = _context.CartTable.Include(x => x.CartDetails).ThenInclude(x => x.Product).Where(x => x.UserID == cookie && !x.IsCompleted && !x.IsDisplay).ToList();
                return(dsdonhangchuathanhtoan);
            }
            return(null);
        }
Пример #9
0
        internal static CartAndUserViewModel DisplayCartAndUserInfo(this DoAnTMDT_Entities _context, HttpContext httpContext, UserManager <ApplicationUser> _userManager, CookieServices _cookieServices)
        {
            string cookie = _cookieServices.ReadCookie(httpContext, "CART_INFORMATION");

            if (cookie != null)
            {
                //_cookieServices.AddCookie(httpContext, "CART_INFORMATION", httpContext.User.FindFirstValue(ClaimTypes.NameIdentifier));
                //Muốn lấy đơn hàng theo điều kiện thì dùng exstension method Where(x => x.Property) ở đoạn code dưới
                //Code dưới hiển thị danh sách chưa đơn hàng chưa được thanh toán
                var dsdonhangduochienthi = _context.CartTable.Include(x => x.CartDetails).ThenInclude(x => x.Product).Where(x => x.UserID == cookie && x.IsDisplay).ToList();
                return(new CartAndUserViewModel(dsdonhangduochienthi, _userManager.Users.Include(x => x.DeliveryInfo).Single(x => x.UserName == httpContext.User.Identity.Name)));
            }
            return(null);
        }
Пример #10
0
        internal static bool ConfirmDeleted(this DoAnTMDT_Entities _context, HttpContext httpContext, CookieServices _cookieServices, string orderID)
        {
            string cookie = _cookieServices.ReadCookie(httpContext, "CART_INFORMATION");

            if (cookie != null)
            {
                try
                {
                    var cartDetailsInDB = _context.CartDetailTable.Include(x => x.Product).Where(x => x.CartID == orderID).ToList();
                    foreach (var cartDetail in cartDetailsInDB)
                    {
                        _context.RemoveFromCart(httpContext, cartDetail.ProductID, cartDetail.Size, (byte)cartDetail.Quantity);
                    }
                    _context.Remove(_context.CartTable.Find(orderID));

                    _context.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
            return(false);
        }
Пример #11
0
        internal static bool ConfirmOrder(this DoAnTMDT_Entities _context, UserManager <ApplicationUser> _userManager, HttpContext httpContext, CookieServices _cookieServices, string orderID)
        {
            string cookie = _cookieServices.ReadCookie(httpContext, "CART_INFORMATION");

            if (cookie != null)
            {
                try
                {
                    var    cartInDB = _context.CartTable.Find(orderID);
                    double pointConverted;
                    if (cartInDB.IsCOD)
                    {
                        cartInDB.IsPayed = true;
                        cartInDB.PayDate = DateTime.Now;
                        pointConverted   = _context.CartDetailTable.Where(x => x.CartID == orderID).Include(x => x.Product).Sum(x => x.Product.ProductPrice * x.Quantity) / 20;
                    }
                    cartInDB.IsCompleted = true;
                    //Tính điểm xu, nếu thanh toán = Paypal thì dc giảm 20% => tổng giá nhân cho (1*0.2)
                    //Xu được tính theo tỉ lệ tổng giá chia 20, khi sử dụng 1 xu tương đương 1$
                    pointConverted = (_context.CartDetailTable.Where(x => x.CartID == orderID).Include(x => x.Product).Sum(x => x.Product.ProductPrice * x.Quantity) * (1 - 0.2) / 20);
                    var user = _userManager.FindByNameAsync(httpContext.User.Identity.Name).Result;
                    user.Point += Convert.ToInt32(pointConverted);
                    _userManager.UpdateAsync(user);

                    _context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            return(false);
        }
Пример #12
0
 public PrivacyController(CookieServices _ICookieServices)
 {
     CookieServices = _ICookieServices;
 }