예제 #1
0
        public BasketForm(DataFormDTO dataFormDTO, ShopBasket basket)
        {
            this.dataFormDTO = dataFormDTO;
            this.basket      = basket;

            dataFormDTO.caller.Hide();
            InitializeComponent();
        }
예제 #2
0
        public ConfirmOrder(DataFormDTO dataFormDTO, ShopBasket basket, user user)
        {
            this.dataFormDTO = dataFormDTO;
            this.basket      = basket;
            this.user        = user;

            InitializeComponent();
        }
예제 #3
0
 public OrderController(IAllOrders allOrders, IAdress adress, ShopBasket shopBasket, UserManager <User> _userManager, IServiceProvider service)
 {
     _allOrders  = allOrders;
     _shopBasket = shopBasket;
     _adress     = adress;
     _service    = service;
     userManager = _userManager;
 }
예제 #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <MotoDBContext>(option => option.UseSqlServer(ConfigString.GetConnectionString("DefaultConnection")));
            services.AddTransient <IAllProducts, MotoRepos>();
            services.AddTransient <IMotoModel, ModelRepos>();
            services.AddTransient <IAllOrders, OrderRepository>();

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(sp => ShopBasket.GetBasket(sp));

            services.AddMvc();
            services.AddMemoryCache();
            services.AddSession();
        }
예제 #5
0
        private void doCrud()
        {
            switch (usage)
            {
            case FormUsage.OrderCar:
                // создание модели авто и самого авто
                // + заказ

                ViewCar car = crud.createModel(modelDTO);
                if (car != null)
                {
                    ShopBasket basket = new ShopBasket();

                    basket.AddItem(car.carId, car.company, car.modelName, car.power, car.colourName, car.autoTrans,
                                   car.manualTrans, modelDTO.price, Convert.ToInt32(RestCarTextBox.Text));

                    //
                    DataFormDTO dto = new DataFormDTO(this, dataFormDTO.mainForm, dataFormDTO.db,
                                                      dataFormDTO.userIdentity, dataFormDTO.userData);

                    BasketForm form = new BasketForm(dto, basket, true);
                    form.Show();
                }

                break;

            case FormUsage.Create:
                // создание модели авто и самого авто

                createCarModel();
                break;

            case FormUsage.Update:
                // обновление модели авто
                //getCarPrice();

                if (crud.update(modelDTO))
                {
                    MessageBox.Show("Car was updated!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Updating was denied");
                }

                break;
            }
        }
예제 #6
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddTransient <IOrderService, OrderService>();
     services.AddDbContext <BookStoreContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
     services.AddIdentity <User, IdentityRole>(opts => {
         opts.User.RequireUniqueEmail = true;
     })
     .AddEntityFrameworkStores <BookStoreContext>();
     services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
     services.AddSingleton <BookFilteringService>();
     services.AddSingleton <AuthorFilteringService>();
     services.AddScoped(sp => ShopBasket.GetBasket(sp));
     services.AddControllersWithViews()
     .AddNewtonsoftJson(options =>
                        options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
     services.AddMemoryCache();
     services.AddSession();
 }
예제 #7
0
        public async Task <IActionResult> Checkout(CheckoutViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            else
            {
                if (!_adress.GetAllAdresses.Any(a => a.Id == model.AdressId))
                {
                    _adress.CreateAdress(new Adress()
                    {
                        Country  = model.Country,
                        City     = model.City,
                        Street   = model.Street,
                        House    = model.House,
                        Building = model.Building,
                        Flat     = model.Flat,
                        Floor    = model.Floor
                    });
                }
                var items = _shopBasket.GetBookBasket();
                _shopBasket.ListBookBasket = items;
                var adress = _adress.GetAdressById(model.AdressId);
                var user   = await userManager.FindByIdAsync(model.UserId);

                var order = new Order()
                {
                    UserId   = model.UserId,
                    User     = user,
                    AdressId = model.AdressId,
                    Adress   = adress,
                    AllPrice = _shopBasket.AllPrice
                };

                _allOrders.CreateOrder(order);
                ShopBasket.CloseSession(_service);
                return(View("Complete", order));
            }
        }
예제 #8
0
        private void initData()
        {
            carViewController = new CarViewController();
            carFilter         = new CarFilter();

            basket = new ShopBasket();

            carFormOperDTO = new CarOperationDTO();

            crud = new CarCrud(dataFormDTO.db);

            ComboBoxDataInit comboBoxData = new ComboBoxDataInit(dataFormDTO.db);

            comboBoxData.addCompanies(cbCarCompany);
            comboBoxData.addColours(cbCarColours);
            comboBoxData.addCarTypes(cbCarTypes);

            List <ViewCar> cars = dataFormDTO.db.ViewCars.Where(o => o.ordered.Equals("n")).ToList();

            dataGridView1.DataSource = cars;
        }
예제 #9
0
 public order CommitTrans(int custID, ShopBasket myCart, out string message)
 {
     message = "Транзакция прошла успешно";
     // Запускаем транзакцию
     using (DbContextTransaction trans = db.Database.BeginTransaction())
     {
         try
         {
             if (myCart.GetTotal() == 0)
             {
                 throw new ApplicationException("Вы забили заполнить корзину!");
             }
             // Сохраняем изменения во всех таблицах
             order o = AddOrder(custID, myCart);
             // Фиксируем транзакцию
             trans.Commit();
             return(o);
         }
         catch (Exception ex)
         {
             // Откатывем транзакцию
             message = "Транзакция откатилась со следующей ошибкой: " +
                       ex.Message;
             trans.Rollback();
             return(null);
         }
         finally
         {
             // Чтобы контекст увидел результаты
             // работы транзакции, надо его пересоздать заново !!!
             // Либо запускать транзакцию внутри блока
             // using (db = new SkladContext()) {... }
             // При пересоздании контекст получает все новые данные из базы
             db.Dispose();
             db = new DbAppContext();
         }
     }
 }
예제 #10
0
        public order AddOrder(int CustID, ShopBasket myCart)
        {
            // Создаем и инициализируем новый заказ
            order o = new order
            {
                userId = CustID // Ид-р заказчика
            };

            db.orders.Add(o); // Добавляем заказ в сущность
                              // Проходим по строкам корзины и добавляем их в детали заказа

            car c;

            foreach (var line in myCart.GetLines())
            {
                c = db.cars.Find(line.ProdID);

                orderDetail ordItems = new orderDetail
                {
                    car      = line.ProdID,
                    car1     = c,
                    total    = 1,
                    amount   = line.Quantity,
                    date     = DateTime.Today,
                    order    = o.orderId,
                    order1   = o,
                    approved = "y"
                };

                // Через навигационное свойство добавляем позицию в заказ
                o.orderDetails.Add(ordItems);
            }
            ;
            db.SaveChanges();
            // Возвращаем новый вставленный заказ
            return(o);
        }
예제 #11
0
 public BooksController(ILogger <HomeController> logger, BookStoreContext context, ShopBasket basket, BookFilteringService bookFilteringService) =>
 (_logger, _context, _basket, _bookFilteringService) = (logger, context, basket, bookFilteringService);
예제 #12
0
 public ShopBasketController(IAllProducts motoRepos, ShopBasket shopBasket)
 {
     MotoRepos = motoRepos;
     SBasket   = shopBasket;
 }
예제 #13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <AppDBContent>(options => options.UseSqlServer(_confString.GetConnectionString("DefaultConnection")));
            services.AddTransient <DBObjects>();
            services.AddTransient <IBooks, BooksRepository>();
            services.AddTransient <IBooksAuthor, AuthorRepository>();
            services.AddTransient <IBooksGenre, GenreRepository>();
            services.AddTransient <IAllOrders, OrdersRepository>();
            services.AddTransient <IAdress, AdressRepository>();
            services.AddTransient <IReviews, ReviewsRepository>();
            services.AddIdentity <User, Role>()
            .AddEntityFrameworkStores <AppDBContent>()
            .AddDefaultTokenProviders();

            services.Configure <IdentityOptions>(opt =>
            {
                //настройки требований к паролю
                //Обязательность использования цифр
                opt.Password.RequireDigit = false;

                //Минимальная длинна пароля
                opt.Password.RequiredLength = 3;

                //Обязательность использования неалфавитных символов
                opt.Password.RequireNonAlphanumeric = false;

                //Настройка требований к пользователю
                //Уникальность почты
                opt.User.RequireUniqueEmail = false;

                //Настройка правил блокировки пользователей
                //Все пользователи изначально разблокированы
                opt.Lockout.AllowedForNewUsers = true;

                //Максимальное количество попыток ввода пароля
                opt.Lockout.MaxFailedAccessAttempts = 10;

                //Время блокировки аккаунта
                opt.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(10);
            });

            services.ConfigureApplicationCookie(opt =>
            {
                //Настройка Cookie
                //Имя
                opt.Cookie.Name = "Book-site";

                //Протокол передачи данных
                opt.Cookie.HttpOnly = true;

                //Время жизни Cookie-файлов
                //opt.Cookie.Expiration= TimeSpan.FromDays(10);
                opt.ExpireTimeSpan = TimeSpan.FromMinutes(10);

                //Перенаправление пользователя на страницу входа при посещении страниц для авторизованных пользователей
                opt.LoginPath  = "/Account/Login";
                opt.LogoutPath = "/Account/Logout";

                //Перенаправление на страницу при отказе в доступе
                opt.AccessDeniedPath = "/Account/AccessDenied";

                //Изменение идентификатора сессии при авторизации пользователя
                opt.SlidingExpiration = true;
            });

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(obj => ShopBasket.GetBasket(obj));

            services.AddMvc(options => options.EnableEndpointRouting = false);
            services.AddMemoryCache();
            services.AddSession();
        }
예제 #14
0
 public OrderController(IAllOrders motoRepos, ShopBasket shopBasket)
 {
     AllOrders = motoRepos;
     ShopB     = shopBasket;
 }
 public OrderController(IOrderService orderService, ShopBasket basket)
 {
     _orderService = orderService;
     _basket       = basket;
 }
예제 #16
0
 public HomeController(IAllProducts motoRepos, ShopBasket shopBasket)
 {
     MRep = motoRepos;
 }
예제 #17
0
 public OrdersRepository(AppDBContent appDbContent, ShopBasket shopBasket)
 {
     _appDbContent = appDbContent;
     _shopBasket   = shopBasket;
 }
예제 #18
0
 public OrderRepository(MotoDBContext motoDBContext, ShopBasket shopBasket)
 {
     this.MotoDB = motoDBContext;
     this.Basket = shopBasket;
 }
예제 #19
0
        public BillPage(ShopBasket basket, bool showShortData = true)
        {
            InitializeComponent();
            var formatted = new FormattedString();

            formatted.Spans.Add(new Span {
                Text = "Время покупки : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = basket.TimeComplete.ToString("HH:MM:ss"), FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            dateLabel.FormattedText = formatted;
            formatted = new FormattedString();
            formatted.Spans.Add(new Span {
                Text = "Номер карты : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = basket.GraphicalNumber, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            grapicalNumber.FormattedText = formatted;
            formatted = new FormattedString();
            formatted.Spans.Add(new Span {
                Text = "Цена без учета скидок и бонусов : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = basket.TotalPrice.ToString("0.00"), FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            formatted.Spans.Add(new Span {
                Text = " " + MobileStaticVariables.MainIssuer.Currency, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            summLabel.FormattedText = formatted;
            formatted = new FormattedString();
            formatted.Spans.Add(new Span {
                Text = "Программа : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = basket.UserProgrammName, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            tariffLabel.FormattedText = formatted;
            formatted = new FormattedString();
            formatted.Spans.Add(new Span {
                Text = "Списано бонусов : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = basket.BonusCountOut.ToString("0.00"), FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            bonusCountOutLabel.FormattedText = formatted;
            formatted = new FormattedString();
            formatted.Spans.Add(new Span {
                Text = "Начислено бонусов : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = basket.BonusCountIn.ToString("0.00"), FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            bonusCountInLabel.FormattedText = formatted;
            formatted = new FormattedString();
            formatted.Spans.Add(new Span {
                Text = "Скидка : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = basket.Discount.ToString("0.00"), FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            formatted.Spans.Add(new Span {
                Text = " " + MobileStaticVariables.MainIssuer.Currency, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            discountLabel.FormattedText = formatted;
            formatted = new FormattedString();
            formatted.Spans.Add(new Span {
                Text = "ИТОГО : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = basket.FinalPrice.ToString("0.00"), FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            formatted.Spans.Add(new Span {
                Text = " " + MobileStaticVariables.MainIssuer.Currency, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            finalCashLabel.FormattedText = formatted;
        }
예제 #20
0
 public BasketController(ShopBasket basket, BookStoreContext context)
 {
     _context = context;
     _basket  = basket;
 }
예제 #21
0
 public ShopBasketController(IAllBooks bookRepository, ShopBasket shopBasket)
 {
     _bookRepository = bookRepository;
     _shopBasket     = shopBasket;
 }
예제 #22
0
 public ShopBasketController(IBooks books, ShopBasket shopBasket, AppDBContent appDBContent)
 {
     _books        = books;
     _shopBasket   = shopBasket;
     _appDBContent = appDBContent;
 }
예제 #23
0
 public OrderService(BookStoreContext context, ShopBasket basket)
 {
     _context = context;
     _basket  = basket;
 }
예제 #24
0
 public BasketComponent(ShopBasket shopBasket) => _shopBasket = shopBasket;
예제 #25
0
 public OrderController(IAllOrders allOrders, ShopBasket shopBasket)
 {
     _allOrders  = allOrders;
     _shopBasket = shopBasket;
 }