private HeadphonesDto MappingHeadphonesToHeadphonesDto(Headphones headphones) { var mapper = new MapperConfiguration(cfg => cfg.CreateMap <Headphones, HeadphonesDto>()).CreateMapper(); var headphonesDto = mapper.Map <Headphones, HeadphonesDto>(headphones); return(headphonesDto); }
public void Update(HeadphonesDto headphonesDto) { Headphones headphones = Database.Headphones.Get(headphonesDto.Id); headphones.Company = headphonesDto.Company; headphones.Description = headphonesDto.Description; headphones.FrequencyRange = headphonesDto.FrequencyRange; headphones.Impedance = headphonesDto.Impedance; headphones.Microphone = headphonesDto.Microphone; headphones.Name = headphonesDto.Name; headphones.Type = headphonesDto.Type; headphones.TypeOfConnection = headphonesDto.TypeOfConnection; if (headphonesDto.Image != null) { headphones.Image = headphonesDto.Image; } if (headphonesDto.Price != 0) { headphones.Price = headphonesDto.Price; } Database.Headphones.Update(headphones); Database.Save(); }
public HeadphonesDto GetHeadphones(int headphonesId) { Headphones headphones = Database.Headphones.Get(headphonesId); HeadphonesDto headphonesDto = MappingHeadphonesToHeadphonesDto(headphones); return(headphonesDto); }
public int Create(HeadphonesDto headphonesDto) { Headphones headphones = MappingHeadphonesDtoToHeadphones(headphonesDto); Database.Headphones.Create(headphones); Database.Save(); return(headphones.Id); }
private void ApplyButton_Click(object sender, EventArgs e) { var output = new LabelOutput(OutputLabel); var smsStorage = new MessageStorage(); var mobilePhone = new MobilePhone(Model.Iphone10, output, smsStorage); output.WriteLine(mobilePhone.GetDescription()); var choice = -1; if (HeadPhonesRadioButton.Checked) { choice = 1; } if (SpeakersRadioButton.Checked) { choice = 2; } if (PhoneSpeakerRadioButton.Checked) { choice = 3; } IPlayback audioDevice = null; if (choice == -1) { return; } if (choice == 1) { audioDevice = new Headphones(output); } else if (choice == 2) { audioDevice = new Speakers(false, output); } else if (choice == 3) { audioDevice = new PhoneSpeaker(output); } else { output.Write("No Valid channel selected"); } if (audioDevice != null) { mobilePhone.InsertEquipmentInJackStick(audioDevice); mobilePhone.AudioInJackStik.Play(new object()); } }
public async Task <int> AddHeadphones(HeadphonesModel headphonesModel, string email) { try { headphonesModel.UserId = (await _context.Users.FirstOrDefaultAsync(user => user.Email == email)).Id; var headphones = new Headphones(headphonesModel); await AddGoodData(headphonesModel.ImageIds, headphones); await _context.Headphones.AddAsync(headphones); await _context.SaveChangesAsync(); return(1); } catch (Exception) { throw; } }
static void Main(string[] args) { char choice; User user1 = new User("Vasyl Netrebiak", "Lesya Ukrainka st.", 3250, 100); FlashDrive flash1 = new FlashDrive("Flash-Royal", 200, "Kingston", 16, "Grey", "Type-C"); Game game1 = new Game("GTA", "Action", 800, "RockStar", "PS4"); Headphones headphones1 = new Headphones("Beats", 600, "Apple", "In-Ear", "White", "Wireless"); Phone phone1 = new Phone("IPhone", 30000, "Apple", 8, 260, "Black", true); Product[] products = new Product[] { flash1, game1, headphones1, phone1 }; Informer informer = new Informer(); Console.WriteLine($"Hello {user1.name}, your balance {user1.balance}"); Console.WriteLine(); Console.WriteLine("There are our products"); for (int i = 0; i < products.Length; i++) { Console.WriteLine($"{i+1}." + products[i].GetInfo()); } while (true) { Console.WriteLine("Choose number of product to add to your purchase list and press Enter:"); string str = Console.ReadLine(); int productNumber = Convert.ToInt32(str); productNumber--; if (productNumber >= 0 && productNumber < products.Length) { if (products[productNumber].price < user1.balance) { user1.listOfPurchase.Add(products[productNumber]); } } else { Console.WriteLine("Incorrect value"); } Console.WriteLine("Do you want add something else?(y/n)"); choice = Char.ToLower(Console.ReadKey().KeyChar); Console.WriteLine(); if (choice == 'y') { continue; } if (choice == 'n') { break; } } Console.WriteLine($"Your balance: {user1.balance}"); Console.WriteLine("Your purchase list:"); informer.ShowPurchaseList(user1); double totalPrice = informer.CountSumOfPurchase(user1); Console.WriteLine("Total cost: " + totalPrice); while (true) { Console.WriteLine("Want to confirm your purchase?(y/n)"); choice = Char.ToLower(Console.ReadKey().KeyChar); Console.WriteLine(); if (choice == 'y') { if (totalPrice <= user1.balance) { informer.Buy(user1); break; } else { Console.WriteLine("insufficient funds"); continue; } } else if (choice == 'n') { break; } else { Console.WriteLine("Icorrect input"); } } Console.WriteLine("Your check"); informer.GiveCheck(); Console.WriteLine("GoodBye"); Console.ReadKey(); GC.Collect(); }