public void OnGetManufacturer(int manufacturerId) { furnitureRepository = new FurnitureRepository(QueryMode.Custom, query: manufacturerId.ToString(), args: "ManufacturerId = @query;"); furnitureRepository.Initialize(); Furniture = furnitureRepository.Items.ToArray(); ViewData["Subtitle"] = "Мебель | Производитель " + ((Furniture.Length == 0) ? "" : Furniture.First().Manufacturer.Name); }
public string Execute(IList <string> commandParameters) { if (commandParameters == null) { throw new ArgumentNullException(NullCollectionOfParameters); } try { this.Model = commandParameters[0]; this.Material = commandParameters[1]; this.Price = decimal.Parse(commandParameters[2]); this.Height = decimal.Parse(commandParameters[3]); } catch (Exception) { return(Messages.InvalidCommandParametersErrorMessage); } var furniture = CreateFurniture(commandParameters.Skip(4).ToList()); bool furnitureIsSaved = FurnitureRepository.Commit(furniture); if (furnitureIsSaved) { return(string.Format(Messages.FurnitureCreatedSuccessMessage, furniture.GetType().Name, this.Model)); } throw new ArgumentException(string.Format(Messages.FurnitureExistsErrorMessage, this.Model)); }
public void OnGetCollection(int collectionId) { furnitureRepository = new FurnitureRepository(QueryMode.Custom, query: collectionId.ToString(), args: "CollectionId = @query;"); furnitureRepository.Initialize(); Furniture = furnitureRepository.Items.ToArray(); ViewData["Subtitle"] = "Мебель | Коллекция " + ((Furniture.Length == 0) ? "" : Furniture.First().Collection.Name); }
public void OnGet(string vendor) { furnitureRepository = new FurnitureRepository(QueryMode.ByVendorCode, vendor); furnitureRepository.Initialize(); Furniture = furnitureRepository.Items.FirstOrDefault(); // Furniture.CategoryID = Furniture.Category.ID; Furniture.ManufacturerID = Furniture.Manufacturer.ID; Furniture.CollectionID = Furniture.Collection.ID; // CollectionRepository = new CollectionRepository(); CollectionRepository.Initialize(); // ManufacturerRepository = new ManufacturerRepository(); ManufacturerRepository.Initialize(); // CategoryRepository = new CategoryRepository(); CategoryRepository.Initialize(); // ColorRepository = new ColorRepository(); ColorRepository.Initialize(); // MaterialRepository = new MaterialRepository(); MaterialRepository.Initialize(); }
public void OnGetCategory(int categoryId) { furnitureRepository = new FurnitureRepository(QueryMode.Custom, query: categoryId.ToString(), args: "CategoryId = @query;"); furnitureRepository.Initialize(); Furniture = furnitureRepository.Items.ToArray(); ViewData["Subtitle"] = "Мебель | Категория " + ((Furniture.Length == 0) ? "" : Furniture.First().Category.Name); }
public void OnGetAll() { furnitureRepository = new FurnitureRepository(); furnitureRepository.Initialize(); Furniture = furnitureRepository.Items.ToArray(); ViewData["Subtitle"] = "Мебель"; }
public void OnGet(string query) { furnitureRepository = new FurnitureRepository(QueryMode.BySearchQuery, query: query); furnitureRepository.Initialize(); Furniture = furnitureRepository.Items.ToArray(); ViewData["Subtitle"] = "Мебель | По запросу: " + query; }
public void OnGet(string vendorCode) { FurnitureRepository furnitureRepository = new FurnitureRepository(QueryMode.ByVendorCode, vendorCode); furnitureRepository.Initialize(); Furniture = furnitureRepository.FirstOrDefault(); if (Furniture != null) { furnitureRepository.IncrementRate(Furniture.VendorCode); } }
public void OnGet() { if (HttpContext.User.Identity.IsAuthenticated) { AppUserRepository userRepository = new AppUserRepository(HttpContext.User.Identity.Name); // email actually userRepository.Initialize(); AppUser = userRepository.FirstOrDefault(); // FurnitureRepository furnitureRepository = new FurnitureRepository(QueryMode.Recommendations, AppUser.ID.ToString()); furnitureRepository.Initialize(); Recommendations = furnitureRepository.Items.Take(3).ToList(); } }
public IActionResult OnPostDeleteMaterial(string vendor, int materialId) { furnitureRepository = new FurnitureRepository(); try { furnitureRepository.DeleteMaterial(vendor, materialId); } catch { Message = "The try to delete material was incorrect."; IsWarningMessage = true; } return(RedirectToPage("Update", "", routeValues: new { vendor }, fragment: "material_form")); }
public App() { InitializeComponent(); UserRepository.GetInstance(); PromoRepository.GetInstance(); CategoryRepository.GetInstance(); ShoppingCardRepository.GetInstance(); CityRepository.GetInstance(); AddressRepository.GetInstance(); FurnitureRepository.GetInstance(); MainPage = new MainPage(); }
public IActionResult OnPostAddColor(string vendor, int colorId) { furnitureRepository = new FurnitureRepository(); try { furnitureRepository.AddColor(vendor, colorId); } catch { Message = "The try to add color was incorrect."; IsWarningMessage = true; } return(RedirectToPage("Update", "", routeValues: new { vendor }, fragment: "color_form")); }
public IActionResult OnPostDeleteSize(string vendor, string type) { type = type ?? ""; furnitureRepository = new FurnitureRepository(); try { furnitureRepository.DeleteSize(vendor, type); } catch { Message = "The try to delete size was incorrect."; IsWarningMessage = true; } return(RedirectToPage("Update", new { vendor })); }
public IActionResult OnPostUpdate() { furnitureRepository = new FurnitureRepository(); try { furnitureRepository.Update(Furniture); } catch { Message = "The try to update was incorrect."; IsWarningMessage = true; return(RedirectToPage("Update", new { vendor = Furniture.VendorCode })); } return(RedirectToPage("Index")); }
public IActionResult OnPostAddSize(string vendor, int w, int h, int d, string type) { type = type ?? ""; furnitureRepository = new FurnitureRepository(); try { Size s = new Size(vendor, type, w, h, d); furnitureRepository.AddSize(vendor, s); } catch { Message = "The try to add size was incorrect."; IsWarningMessage = true; } return(RedirectToPage("Update", new { vendor })); }
public void Handler_Should_Be_Invalid_When_Email_Is_NotEmail() { var repAcommodation = new AcommodationRepository(); var repFurniture = new FurnitureRepository(); var payService = new PaymentService(); var handler = new FurnitureReservationHandler(repFurniture, repAcommodation, payService); var user = new User("Matheus barbosa", "notemail", new Adress("Rua x", "123", "SÃO PAULO")); var furniture = new Furniture("Descriçao", new Adress("Rua y", "321", "SÃO PAULO")); var payment = new Payment(500, 500); var commandRequest = new FurnitureReservationRequest() { User = user, Furniture = furniture, Payment = payment, Checkin = DateTime.Now, Checkout = DateTime.Now.AddDays(3) }; var res = handler.Handle(commandRequest, new System.Threading.CancellationToken()); Assert.True(handler.Contract.Invalid); }
public void Handler_Should_Be_Invalid_When_Payment_Is_Invalid() { var repAcommodation = new AcommodationRepository(); var repFurniture = new FurnitureRepository(); var payService = new PaymentService(); payService.throwException = true; var handler = new FurnitureReservationHandler(repFurniture, repAcommodation, payService); var user = new User("", "*****@*****.**", new Adress("Rua x", "123", "SÃO PAULO")); var furniture = new Furniture("", new Adress("Rua y", "321", "SÃO PAULO")); var payment = new Payment(500, 200); var commandRequest = new FurnitureReservationRequest() { User = user, Furniture = furniture, Payment = payment, Checkin = DateTime.Now, Checkout = DateTime.Now.AddDays(3) }; var res = handler.Handle(commandRequest, new System.Threading.CancellationToken()); Assert.True(handler.Contract.Invalid && res.Result.Errors.Count == 3); }
public void Debugger_Test_for_see_notifications() { var repAcommodation = new AcommodationRepository(); var repFurniture = new FurnitureRepository(); var payService = new PaymentService(); var handler = new FurnitureReservationHandler(repFurniture, repAcommodation, payService); var user = new User("", "*****@*****.**", new Adress("Rua x", "123", "SÃO PAULO")); var furniture = new Furniture("", new Adress("Rua y", "321", "SÃO PAULO")); var payment = new Payment(500, 200); var commandRequest = new FurnitureReservationRequest() { User = user, Furniture = furniture, Payment = payment, Checkin = DateTime.Now, Checkout = DateTime.Now.AddDays(3) }; var res = handler.Handle(commandRequest, new System.Threading.CancellationToken()); Assert.True(handler.Contract.Invalid); }
public IActionResult OnPostSetSale(string vendor, bool enabled, int price) { furnitureRepository = new FurnitureRepository(); try { if (enabled) { furnitureRepository.SetDiscount(vendor, price); } else { furnitureRepository.RemoveDiscount(vendor); } } catch { Message = "The try to update was incorrect."; IsWarningMessage = true; return(RedirectToPage("Update", new { vendor })); } return(RedirectToPage("Index")); }
public IActionResult OnPostCreate(IFormFile image) { try { Furniture.Image = Models.Furniture.GetFileName(Furniture, image.FileName); FurnitureRepository furnitureRepository = new FurnitureRepository(); furnitureRepository.Create(Furniture); if (image != null) { using (var fs = new FileStream(_env.WebRootPath + Furniture.Image, FileMode.Create)) { image.CopyTo(fs); } } } catch (Exception) { Message = "The try to create was incorrect."; IsWarningMessage = true; return(RedirectToPage()); } return(RedirectToPage("Index")); }
public StatisticsModel() { orderRepository = new OrderRepository(); orderRepository.Initialize(); userRepository = new AppUserRepository(); userRepository.Initialize(); furnitureRepository = new FurnitureRepository(); furnitureRepository.Initialize(); categoryRepository = new CategoryRepository(); categoryRepository.Initialize(); manufacturerRepository = new ManufacturerRepository(); manufacturerRepository.Initialize(); // // AppUserTotalStats = orderRepository.Items.GroupBy(oh => new { ID = oh.AppUserID, Name = oh.AppUser.Name }) .Select(g => new AppUserTotal(g.Key.ID, g.Key.Name, g.Sum(oh => oh.GetSum()))) .OrderByDescending(ut => ut.Total); // IEnumerable <int> totals = orderRepository.Items .Where(oh => oh.Date != null) .Select(oh => (int)oh.GetSum()); ReceiptStats = (totals.Min(), (int)totals.Average(), totals.Max()); // categoryManufacturerAverage = new Dictionary <string, Dictionary <string, List <decimal> > >(); furnitureRepository.Items.ForEach(f => { if (categoryManufacturerAverage.ContainsKey(f.Category.Name)) { if (categoryManufacturerAverage[f.Category.Name].ContainsKey(f.Manufacturer.Name)) { categoryManufacturerAverage[f.Category.Name][f.Manufacturer.Name].Add(f.Price); } else { categoryManufacturerAverage[f.Category.Name][f.Manufacturer.Name] = new List <decimal>(); categoryManufacturerAverage[f.Category.Name][f.Manufacturer.Name].Add(f.Price); } } else { categoryManufacturerAverage[f.Category.Name] = new Dictionary <string, List <decimal> >(); categoryManufacturerAverage[f.Category.Name][f.Manufacturer.Name] = new List <decimal>(); categoryManufacturerAverage[f.Category.Name][f.Manufacturer.Name].Add(f.Price); } }); // foreach (var oh in orderRepository.Items) { if (oh.Date == null) { continue; } // DateTime date = ((DateTime)oh.Date).Date; int numberOfOrders = 1; if (ordersByDate.ContainsKey(date)) { numberOfOrders += ordersByDate[date]; } ordersByDate[date] = numberOfOrders; // oh.OrderDetails.ForEach(od => { int bought = od.Quantity; if (furnitureBought.ContainsKey(od.VendorCode)) { bought += furnitureBought[od.VendorCode]; } furnitureBought[od.VendorCode] = bought; }); } }
public XLWorkbook Export(search materials) { Dictionary <string, List <Material> > materialDict = search.GetResult(materials); var workbook = new XLWorkbook(); foreach (var item in materialDict) { var sheetName = item.Key; switch (sheetName) { case "notebook": sheetName = "Notebooks"; break; case "display": sheetName = "Bildschirme"; break; case "book": sheetName = "Bücher"; break; case "equipment": sheetName = "Zubehör"; break; case "furniture": sheetName = "Mobiliar"; break; } if (item.Value.Count > 0) { var worksheet = workbook.Worksheets.Add(sheetName); if (sheetName.Equals("Notebooks")) { worksheet.Cell(1, 2).Value = "Marke"; worksheet.Cell(1, 3).Value = "Modell"; worksheet.Cell(1, 4).Value = "Seriennummer"; worksheet.Cell(1, 5).Value = "Vorname"; worksheet.Cell(1, 6).Value = "Nachname"; worksheet.Cell(1, 7).Value = "Räumlichkeit"; } if (sheetName.Equals("Bildschirme")) { worksheet.Cell(1, 2).Value = "Marke"; worksheet.Cell(1, 3).Value = "Modell"; worksheet.Cell(1, 4).Value = "Seriennummer"; worksheet.Cell(1, 5).Value = "Räumlichkeit"; worksheet.Cell(1, 6).Value = "Anzahl"; } if (sheetName.Equals("Bücher")) { worksheet.Cell(1, 2).Value = "Titel"; worksheet.Cell(1, 3).Value = "ISBN"; worksheet.Cell(1, 4).Value = "Vorname"; worksheet.Cell(1, 5).Value = "Nachname"; worksheet.Cell(1, 6).Value = "Räumlichkeit"; worksheet.Cell(1, 7).Value = "Anzahl"; } if (sheetName.Equals("Zubehör")) { worksheet.Cell(1, 2).Value = "Art"; worksheet.Cell(1, 3).Value = "Marke"; worksheet.Cell(1, 4).Value = "Modell"; worksheet.Cell(1, 5).Value = "Vorname"; worksheet.Cell(1, 6).Value = "Nachname"; worksheet.Cell(1, 7).Value = "Räumlichkeit"; worksheet.Cell(1, 8).Value = "Anzahl"; } if (sheetName.Equals("Mobiliar")) { worksheet.Cell(1, 2).Value = "Art"; worksheet.Cell(1, 3).Value = "Räumlichkeit"; worksheet.Cell(1, 4).Value = "Anzahl"; } for (int i = 0; i < item.Value.Count; i++) { var item1 = item.Value[i]; worksheet.Cell(1, 1).Value = "ID"; worksheet.Cell(i + 2, 1).Value = item1.id; if (item1.GetType() == typeof(notebook)) { NotebookRepository Repo = new NotebookRepository(entities); Repo.GetRelation(); var notebook = (notebook)item1; worksheet.Cell(i + 2, 2).Value = notebook.make; worksheet.Cell(i + 2, 3).Value = notebook.model; worksheet.Cell(i + 2, 4).Value = notebook.serial_number; if (notebook.person != null) { worksheet.Cell(i + 2, 5).Value = notebook.person.name1; worksheet.Cell(i + 2, 6).Value = notebook.person.name2; } if (notebook.classroom != null) { worksheet.Cell(i + 2, 7).Value = notebook.classroom.room; } worksheet.Columns().AdjustToContents(); worksheet.Rows().AdjustToContents(); } else if (item1.GetType() == typeof(display)) { DisplayRepository Repo = new DisplayRepository(entities); Repo.GetRelation(); var display = (display)item1; worksheet.Cell(i + 2, 2).Value = display.make; worksheet.Cell(i + 2, 3).Value = display.model; if (display.serial_number != null) { worksheet.Cell(i + 2, 4).Value = display.serial_number; } if (display.classroom != null) { worksheet.Cell(i + 2, 5).Value = display.classroom.room; } if (display.quantity != null) { worksheet.Cell(i + 2, 6).Value = display.quantity; } worksheet.Columns().AdjustToContents(); worksheet.Rows().AdjustToContents(); } else if (item1.GetType() == typeof(book)) { BookRepository Repo = new BookRepository(entities); Repo.GetRelation(); var book = (book)item1; worksheet.Cell(i + 2, 2).Value = book.title; worksheet.Cell(i + 2, 3).Value = book.isbn; if (book.person != null) { worksheet.Cell(i + 2, 4).Value = book.person.name1; worksheet.Cell(i + 2, 5).Value = book.person.name2; } if (book.classroom != null) { worksheet.Cell(i + 2, 6).Value = book.classroom.room; } if (book.quantity != null) { worksheet.Cell(i + 2, 7).Value = book.quantity; } worksheet.Columns().AdjustToContents(); worksheet.Rows().AdjustToContents(); } else if (item1.GetType() == typeof(equipment)) { EquipmentRepository Repo = new EquipmentRepository(entities); Repo.GetRelation(); var equipment = (equipment)item1; worksheet.Cell(i + 2, 2).Value = equipment.type; if (equipment.make != null) { worksheet.Cell(i + 2, 3).Value = equipment.make; } if (equipment.model != null) { worksheet.Cell(i + 2, 4).Value = equipment.model; } if (equipment.person != null) { worksheet.Cell(i + 2, 5).Value = equipment.person.name1; worksheet.Cell(i + 2, 6).Value = equipment.person.name2; } if (equipment.classroom != null) { worksheet.Cell(i + 2, 7).Value = equipment.classroom.room; } if (equipment.quantity != null) { worksheet.Cell(i + 2, 8).Value = equipment.quantity; } worksheet.Columns().AdjustToContents(); worksheet.Rows().AdjustToContents(); } else if (item1.GetType() == typeof(furniture)) { FurnitureRepository Repo = new FurnitureRepository(entities); Repo.GetRelation(); var furniture = (furniture)item1; worksheet.Cell(i + 2, 2).Value = furniture.type; if (furniture.classroom != null) { worksheet.Cell(i + 2, 3).Value = furniture.classroom.room; } if (furniture.quantity != null) { worksheet.Cell(i + 2, 4).Value = furniture.quantity; } worksheet.Columns().AdjustToContents(); worksheet.Rows().AdjustToContents(); } } } } return(workbook); }
public FurnitureService(FurnitureRepository repository, ILogger <FurnitureService> logger) { _repository = repository; _logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="FurnitureController" /> class. /// </summary> public FurnitureController() { this.theRepository = new FurnitureRepository(); }
public IndexModel() { furnitureRepository = new FurnitureRepository(); }