コード例 #1
0
        public IActionResult SiparisiTamamla()
        {
            var cart = _cartService.GetCartByUserId(_userManager.GetUserId(User));

            var orderModel = new OrderModel();

            orderModel.CartModel = new CartModel()
            {
                CartId    = cart.Id,
                CartItems = cart.CartItems.Select(i => new CartItemModel()
                {
                    CartItemId = i.Id,
                    ProductId  = i.Product.ProductId,
                    Name       = i.Product.ProductName,
                    Price      = (decimal)i.Product.ProductUnitPrice,
                    ImageUrl   = i.Product.ImageUrl,
                    Quantity   = i.Quantity
                }).ToList()
            };
            orderModel.BuyerId = _usersAndBuyersService.GetByUserId(_userManager.GetUserId(User)).BuyerId;

            return(View(orderModel));
        }
コード例 #2
0
        public IActionResult Ayarlar()
        {
            var usersAndProfile          = _usersAndBuyersService.GetByUserId(_userManager.GetUserId(User));
            var buyerId                  = usersAndProfile.BuyerId;
            var buyer                    = _buyerService.GetById(buyerId);
            var profileSettingsViewModel = new ProfileSettingsViewModel
            {
                BuyerId         = buyer.BuyerId,
                BuyerName       = buyer.BuyerName,
                Adress          = buyer.Adress,
                Email           = buyer.Email,
                PhoneNumber     = buyer.PhoneNumber,
                ProfileImageUrl = buyer.ProfileImageUrl
            };

            return(View(profileSettingsViewModel));
        }
コード例 #3
0
        public async Task <IActionResult> GirisYap(LoginModel model, string returnUrl = null)
        {
            returnUrl = returnUrl ?? "~/";
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = await _userManager.FindByNameAsync(model.UserName);

            if (user == null)
            {
                ModelState.AddModelError("", "Böyle bir koleksiyoncu bulunamadı.");
                return(View(model));
            }
            if (!await _userManager.IsEmailConfirmedAsync(user))
            {
                ModelState.AddModelError("", "Bu hesap e-posta ile onaylanmamış.");
                return(View(model));
            }
            if (!await _userManager.IsInRoleAsync(user, "Buyer"))
            {
                ModelState.AddModelError("", "Bu hesap satıcı hesabı değil!");
                return(View(model));
            }
            var result = await _signInManager.PasswordSignInAsync(model.UserName, model.Password, true, false);

            if (result.Succeeded)
            {
                var buyerId = _userAndBuyersService.GetByUserId(user.Id).BuyerId;
                var buyer   = _buyerService.GetById(buyerId);
                buyer.LastLoginDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                _buyerService.Update(buyer);
                return(Redirect(returnUrl));
            }
            ModelState.AddModelError("", "Kullanıcı adı veya parola yanlış!");
            return(View(model));
        }