public BasketForm(DataFormDTO dataFormDTO, ShopBasket basket) { this.dataFormDTO = dataFormDTO; this.basket = basket; dataFormDTO.caller.Hide(); InitializeComponent(); }
public ConfirmOrder(DataFormDTO dataFormDTO, ShopBasket basket, user user) { this.dataFormDTO = dataFormDTO; this.basket = basket; this.user = user; InitializeComponent(); }
public OrderController(IAllOrders allOrders, IAdress adress, ShopBasket shopBasket, UserManager <User> _userManager, IServiceProvider service) { _allOrders = allOrders; _shopBasket = shopBasket; _adress = adress; _service = service; userManager = _userManager; }
// 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(); }
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; } }
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(); }
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)); } }
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; }
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(); } } }
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); }
public BooksController(ILogger <HomeController> logger, BookStoreContext context, ShopBasket basket, BookFilteringService bookFilteringService) => (_logger, _context, _basket, _bookFilteringService) = (logger, context, basket, bookFilteringService);
public ShopBasketController(IAllProducts motoRepos, ShopBasket shopBasket) { MotoRepos = motoRepos; SBasket = shopBasket; }
// 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(); }
public OrderController(IAllOrders motoRepos, ShopBasket shopBasket) { AllOrders = motoRepos; ShopB = shopBasket; }
public OrderController(IOrderService orderService, ShopBasket basket) { _orderService = orderService; _basket = basket; }
public HomeController(IAllProducts motoRepos, ShopBasket shopBasket) { MRep = motoRepos; }
public OrdersRepository(AppDBContent appDbContent, ShopBasket shopBasket) { _appDbContent = appDbContent; _shopBasket = shopBasket; }
public OrderRepository(MotoDBContext motoDBContext, ShopBasket shopBasket) { this.MotoDB = motoDBContext; this.Basket = shopBasket; }
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; }
public BasketController(ShopBasket basket, BookStoreContext context) { _context = context; _basket = basket; }
public ShopBasketController(IAllBooks bookRepository, ShopBasket shopBasket) { _bookRepository = bookRepository; _shopBasket = shopBasket; }
public ShopBasketController(IBooks books, ShopBasket shopBasket, AppDBContent appDBContent) { _books = books; _shopBasket = shopBasket; _appDBContent = appDBContent; }
public OrderService(BookStoreContext context, ShopBasket basket) { _context = context; _basket = basket; }
public BasketComponent(ShopBasket shopBasket) => _shopBasket = shopBasket;
public OrderController(IAllOrders allOrders, ShopBasket shopBasket) { _allOrders = allOrders; _shopBasket = shopBasket; }