public ICollection <NailPolish> GetNailPolishes() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; List <NailPolish> NailPolishes = new List <NailPolish>(); while (file.ReadLine() != null) { string name = file.ReadLine(); string brand = file.ReadLine(); string stringPrice = file.ReadLine(); decimal price = decimal.Parse(stringPrice); var nailPolish = new NailPolish() { Name = name, Brand = brand, Price = price }; NailPolishes.Add(nailPolish); } this.file.Close(); return(NailPolishes); }
protected override void Seed(NailPolishMarketDbContext context) { var first = new NailPolish { Name = "FirstNailPolish", Price = 4.5M }; var second = new NailPolish { Name = "SecondNailPolish", Price = 5.0M }; var firstCatalog = new Catalog(); firstCatalog.Name = "My First Catalog"; firstCatalog.Date = DateTime.Now; firstCatalog.NailPolishes.Add(second); context.Catalogs.Add(firstCatalog); context.SaveChanges(); var firstUser = new User { UserName = "******" }; var firstOrder = new Order { Date = DateTime.Now }; // firstOrder.NailPolishes.Add(second); // firstOrder.User = firstUser; context.NailPolishes.Add(first); context.NailPolishes.Add(second); context.SaveChanges(); context.Orders.Add(firstOrder); context.SaveChanges(); var fileReader = new FileReader(@"E:\test.txt"); var nailPolishes = fileReader.GetNailPolishes(); fileReader.CloseFile(); foreach (var item in nailPolishes) { context.NailPolishes.Add(item); } context.SaveChanges(); // var userRepository = new EfRepository<User>(); // userRepository.Add(new User { UserName = "******" }); // userRepository.Add(new User { UserName = "******" }); // // var orderRepository = new EfRepository<Order>(); // orderRepository.Add(new Order { Date = DateTime.Now }); }
public override void LoadDataToComponets(CosmeticProduct currentProduct, Control.ControlCollection controls) { base.LoadDataToComponets(currentProduct, controls); Control[] controlList = GetComponentsForInput(controls); NailPolish currentNailPolish = (NailPolish)currentProduct; controlList[durabilityIndex].Text = Convert.ToString(currentNailPolish.Durability); ComboBox temp = (ComboBox)controlList[effectIndex]; temp.SelectedValue = Enum.GetName(typeof(NailPolish.TypesOfEffects), currentNailPolish.SpecialEffect); }
static void Main(string[] args) { Database.SetInitializer( new MigrateDatabaseToLatestVersion <NailPolishMarketDbContext, Configuration>()); // INailPolishMarketDbContext db = new NailPolishMarketDbContext(); // // db.Catalogs.Count(); // // var nailPolish = new NailPolish // { // Name = "Classic Nail Lacquer", // Brand = "OPI", // Price = 12.50M // }; // // db.NailPolishes.Add(nailPolish); // db.SaveChanges(); // // Console.WriteLine(db.NailPolishes.Count()); var data = new NailPolishMarketData(); var newNailPolish = new NailPolish(); newNailPolish.Name = "New Nailpolish 1"; data.NailPolishes.Add(newNailPolish); data.SaveChanges(); var newCatalog = new Catalog(); newCatalog.Name = "New Catalog 1"; newCatalog.Date = DateTime.Now; data.Catalogs.Add(newCatalog); data.SaveChanges(); var user = new User(); data.Users.Add(user); data.SaveChanges(); var order = new Order(); order.Date = DateTime.Now; order.NailPolishes.Add(newNailPolish); data.Orders.Add(order); data.SaveChanges(); }
public NailPolish ConvertPolishToDTO(BllNailPolish bllNailPolish) { NailPolish dTOPolish = new NailPolish() { Id = bllNailPolish.Id, Name = bllNailPolish.Name, Brand = bllNailPolish.Brand, Price = bllNailPolish.Price, Volume = bllNailPolish.Volume, QuantityBottles = bllNailPolish.QuantityBottles, QuantityGeneralVolume = bllNailPolish.QuantityGeneralVolume, Color = bllNailPolish.Color, QuntityCount = bllNailPolish.QuntityCount }; return(dTOPolish); }
public BllNailPolish ConvertPolishToBLL(NailPolish dTOPolish) { BllNailPolish bllNailPolish = new BllNailPolish() { Id = dTOPolish.Id, Name = dTOPolish.Name, Brand = dTOPolish.Brand, Price = dTOPolish.Price, Volume = dTOPolish.Volume, QuantityBottles = dTOPolish.QuantityBottles, QuantityGeneralVolume = dTOPolish.QuantityGeneralVolume, Color = dTOPolish.Color, QuntityCount = dTOPolish.QuntityCount }; return(bllNailPolish); }
public override void GetDataFromComponents(CosmeticProduct currentProduct, Control.ControlCollection controls) { base.GetDataFromComponents(currentProduct, controls); Control[] controlList = GetComponentsForInput(controls); NailPolish currentNailPolish = (NailPolish)currentProduct; try { currentNailPolish.Durability = Convert.ToInt32(controlList[durabilityIndex].Text); } catch { throw new Exception(); } ComboBox temp = (ComboBox)controlList[effectIndex]; currentNailPolish.SpecialEffect = (NailPolish.TypesOfEffects)Enum.Parse(typeof(NailPolish.TypesOfEffects), temp.SelectedValue.ToString()); }
private void Add(object sender, RoutedEventArgs e) { foreach (var item in StockRoom.Items) { if ((item as TabItem).IsSelected) { if ((item as TabItem).Header.ToString() == "Shampoo") { AddMaterial(new Shampoo()); } else if ((item as TabItem).Header.ToString() == "Balsam") { AddMaterial(new Balsam()); } else if ((item as TabItem).Header.ToString() == "Color") { HairColor hairColor = new HairColor { Color = color.Text, Description = description.Text }; AddMaterial(hairColor); } else if ((item as TabItem).Header.ToString() == "Laque") { AddMaterial(new Laque()); } else if ((item as TabItem).Header.ToString() == "Powder") { Powder powder = new Powder { Color = color.Text }; AddMaterial(powder); } else if ((item as TabItem).Header.ToString() == "Foundation") { Foundation foundation = new Foundation { Color = color.Text, Description = description.Text }; AddMaterial(foundation); } else if ((item as TabItem).Header.ToString() == "Shadow") { Shadows shadows = new Shadows { Color = color.Text }; AddMaterial(shadows); } else if ((item as TabItem).Header.ToString() == "Lipstick") { Lipstick lipstick = new Lipstick { Color = color.Text, Description = description.Text }; AddMaterial(lipstick); } else if ((item as TabItem).Header.ToString() == "Mascara") { Mascara mascara = new Mascara { Color = color.Text, }; AddMaterial(mascara); } else if ((item as TabItem).Header.ToString() == "NailBase") { AddMaterial(new NailBase()); } else if ((item as TabItem).Header.ToString() == "NailTop") { AddMaterial(new NailTop()); } else if ((item as TabItem).Header.ToString() == "NailEnamel") { NailPolish nailPolish = new NailPolish { Color = color.Text, }; AddMaterial(nailPolish); } } } load(null, null); }