public void Add(ComputerPart Updatedentity) { var newData = Mapper.Map <tblComputerPart>(Updatedentity); Entities.tblComputerParts.Add(newData); Entities.SaveChanges(); }
private async void MenuItemSelected(object sender, EventArgs e) { //itemsList.SelectedItem; MasterDetailPage masterDetailPage = (MasterDetailPage)Application.Current.MainPage; NavigationPage navPage = (NavigationPage)masterDetailPage.Detail; //NavigationPage navPage = (NavigationPage)Application.Current.MainPage; IReadOnlyList <Page> navStack = navPage.Navigation.NavigationStack; IndependentChoicePage independentChoicePage = navStack[navPage.Navigation.NavigationStack.Count - 2] as IndependentChoicePage; if (independentChoicePage != null) { ComputerPart computerPart = new ComputerPart() { ModelName = "gugu", Manufacturer = "gugugug" }; //ComputerPart computerPart = itemsList.SelectedItem as ComputerPart; //this.Display(computerPart.Manufacturer); independentChoicePage.SelectedParts.Add(computerPart); //independentChoicePage.SelectedParts.Add(new ComputerPart { Manufacturer = "asdf", ModelName = "dfsg", Price = 111 }); } //ComputerPart computerPart = itemsList.SelectedItem as ComputerPart; //this.DisplayAlert(computerPart.ModelName, computerPart.Price.ToString(), "OK"); MessagingCenter.Send <Page>(this, "ItemSelected"); await this.Navigation.PopAsync(); }
public void RemovePart_RemoveOneItem_EmptyBoundedParts() { var mockComputerPartsService = new Mock <IComputerPartsService>(); mockComputerPartsService .Setup(x => x.GetComputerParts(It.IsAny <string>(), It.IsAny <string>())) .Returns(new List <ComputerPartDTO>()); mockComputerPartsService .Setup(x => x.Delete(It.IsAny <int>())); MainViewModel vm = new MainViewModel(mockComputerPartsService.Object); ComputerPart part = new ComputerPart() { Id = 12345 }; vm.BoundedParts.Add(part); vm.RemovePart(part); mockComputerPartsService.Verify(x => x.Delete(It.Is <int>(n => n == 12345)), Times.Once()); Assert.AreEqual(0, vm.BoundedParts.Count); }
public ActionResult DeleteConfirmed(int id) { ComputerPart computerPart = db.ComputerParts.Find(id); db.ComputerParts.Remove(computerPart); db.SaveChanges(); return(RedirectToAction("Index")); }
public void EditPart_WithinConditionAndTypeFilters_UpdatedOnBoundedPartsAndComputerPartsService() { var mockComputerPartsService = new Mock <IComputerPartsService>(); const int id = 12345; mockComputerPartsService .Setup(x => x.GetComputerParts(It.IsAny <string>(), It.IsAny <string>())) .Returns(new List <ComputerPartDTO>()); mockComputerPartsService .Setup(x => x.Update(It.IsAny <int>(), It.IsAny <ComputerPartDetailDTO>())); MainViewModel vm = new MainViewModel(mockComputerPartsService.Object); vm.Condition = "Good"; vm.PartType = "Motherboard"; ComputerPart part = new ComputerPart { Id = id, Condition = "Good", Description = "some description", PartType = "Motherboard" }; vm.BoundedParts.Add(part); ComputerPartDetail partDetail = new ComputerPartDetail { Id = part.Id, Condition = part.Condition, Description = part.Description, PartType = part.PartType, Price = 1.2M, Location = "some location", Remarks = "some text" }; vm.EditPart(part, partDetail); mockComputerPartsService.Verify( x => x.Update(It.Is <int>(n => n == 12345), It.IsAny <ComputerPartDetailDTO>()), Times.Once()); Assert.AreEqual(1, vm.BoundedParts.Count); vm.Condition = "All"; vm.PartType = "All"; vm.EditPart(part, partDetail); mockComputerPartsService.Verify( x => x.Update(It.Is <int>(n => n == 12345), It.IsAny <ComputerPartDetailDTO>()), Times.Exactly(2)); Assert.AreEqual(1, vm.BoundedParts.Count); }
public void ModifyComputerPart(ComputerPart computerPart) { EditorWindow editorWindow = new EditorWindow(computerPart); if (editorWindow.ShowDialog() == true) { //Do nothing } }
public void SetSelectedValue(SelectList Parts, ComputerPart Cp) { var selected = Parts.Where(x => x.Value.Equals(Cp.Part.Id.ToString())).FirstOrDefault(); if (selected != null) { selected.Selected = true; } }
public SingleItemPage(ComputerPart item) { InitializeComponent(); //Test(item.WhoIs.ToString()); //this.Title = item.ModelName; this.BindingContext = item; switch (item.WhoIs) { case computerParts.CASE: this.Children.Add(new CaseDescriptionPage(item)); break; case computerParts.CPU: this.Children.Add(new CPUDescriptionPage(item)); break; case computerParts.HDD: this.Children.Add(new HDDDescriptionPage(item)); break; case computerParts.MOTHERBOARD: this.Children.Add(new MotherboardDescriptionPage(item)); break; case computerParts.POWERSUPPLY: this.Children.Add(new PowerSupplyDescriptionPage(item)); break; case computerParts.RAM: this.Children.Add(new RAMDescriptionPage(item)); break; case computerParts.VIDEOCARD: this.Children.Add(new VideocardDescriptionPage(item)); break; } Shops shopsPage = new Shops(item); Ads adsPage = new Ads(item); Reviews reviewsPage = new Reviews(item); Comments commentsPage = new Comments(item); //this.Children.Add(descriptionPage); this.Children.Add(shopsPage); this.Children.Add(adsPage); this.Children.Add(reviewsPage); this.Children.Add(commentsPage); IEnumerator <Page> enumerator = Children.GetEnumerator(); while (enumerator.MoveNext()) { enumerator.Current.BindingContext = item; } }
private async void ItemTabbedInList(object sender, ItemTappedEventArgs e) { ComputerPart computerPart = e.Item as ComputerPart; if (computerPart != null) { //await this.Navigation.PushAsync(new SingleItemPage(computerPart.ModelName)); await this.Navigation.PushAsync(new SingleItemPage(computerPart)); } }
public void RemovePart(Object obj) { ComputerPart part = (ComputerPart)obj; // remove from list view this.BoundedParts.Remove(part); // remove from db this._computerPartsService.Delete(part.Id); }
public ActionResult Edit([Bind(Include = "Id,Name,Amount,Price,Vendor")] ComputerPart computerPart) { if (ModelState.IsValid) { db.Entry(computerPart).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(computerPart)); }
public void AddComputerPart(string PartName, int PartTypeId, double price) { var cPart = new ComputerPart { PartName = PartName, PartTypeId = PartTypeId, Price = price }; _UnitOfWork.ComputerParts.Add(cPart); }
public ActionResult Create([Bind(Include = "Id,Name,Amount,Price,Vendor")] ComputerPart computerPart) { if (ModelState.IsValid) { db.ComputerParts.Add(computerPart); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(computerPart)); }
public void Update(ComputerPart entity) { var data = Entities.tblComputerParts.FirstOrDefault(d => d.id == entity.id); if (data == null) { return; } data.Price = entity.Price; data.PartName = entity.PartName; Entities.SaveChanges(); }
// GET: ComputerPart/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ComputerPart computerPart = db.ComputerParts.Find(id); if (computerPart == null) { return(HttpNotFound()); } return(View(computerPart)); }
public void PropertyChanged_Type() { var result = false; ComputerPart vm = new ComputerPart(); vm.PropertyChanged += (s, e) => { if (e.PropertyName == "PartType") { result = true; } }; vm.PartType = "some text"; Assert.IsTrue(result); }
public void PropertyChanged_Condition() { var result = false; ComputerPart vm = new ComputerPart(); vm.PropertyChanged += (s, e) => { if (e.PropertyName == "Condition") { result = true; } }; vm.Condition = "some text"; Assert.IsTrue(result); }
public void AddPart(ComputerPartDetail partDetail) { // update db int id = this._computerPartsService.Append(DTOConverter.FromComputerPartDetail(partDetail)); // update list view if within Condition/Type filters if ((Condition == "All" || Condition == partDetail.Condition) && (PartType == "All" || PartType == partDetail.PartType)) { ComputerPart part = new ComputerPart { Id = id, // on selected item (ListView), the id is use for edit or delete db query Description = partDetail.Description, Condition = partDetail.Condition, PartType = partDetail.PartType }; this.BoundedParts.Add(part); } }
public async Task <int> AddComputerPart(ComputerPartModel computerPartModel, string email) { try { computerPartModel.UserId = (await _context.Users.FirstOrDefaultAsync(user => user.Email == email)).Id; var computerPart = new ComputerPart(computerPartModel); await AddGoodData(computerPartModel.ImageIds, computerPart); await _context.ComputerParts.AddAsync(computerPart); await _context.SaveChangesAsync(); return(1); } catch (Exception) { throw; } }
public void EditPart(ComputerPart part, ComputerPartDetail partDetail) { // update db this._computerPartsService.Update(part.Id, DTOConverter.FromComputerPartDetail(partDetail)); // update list view if within Condition/Type filters if ((Condition == "All" || Condition == partDetail.Condition) && (PartType == "All" || PartType == partDetail.PartType)) { // update list view, boundedParts are updated automatically part.Description = partDetail.Description; part.Condition = partDetail.Condition; part.PartType = partDetail.PartType; } else { // otherwise, remove from list view this.BoundedParts.Remove(part); } }
public CaseDescriptionPage(ComputerPart item) { InitializeComponent(); this.BindingContext = item; //DescriptionItems = new List<DescriptionItem> //{ // new DescriptionItem {DescriptionName = "Тип корпуса", DescriptionHelp = "dfsfg"}, // new DescriptionItem {DescriptionName = "Блок питания", DescriptionHelp = "dfsfg"}, // new DescriptionItem {DescriptionName = "Материал корпуса", DescriptionHelp = "dfsfg"}, // new DescriptionItem {DescriptionName = "Форм-фактор материнской платы", DescriptionHelp = "dfsfg"}, // new DescriptionItem {DescriptionName = "Поддержка жидкостного охлаждения", DescriptionHelp = "dfsfg"}, // new DescriptionItem {DescriptionName = "Прозрачное окно", DescriptionHelp = "dfsfg"}, // new DescriptionItem {DescriptionName = "Макс. длина видеокарты", DescriptionHelp = "dfsfg"}, // new DescriptionItem {DescriptionName = "Макс. высота процессорного кулера", DescriptionHelp = "dfsfg"}, // new DescriptionItem {DescriptionName = "Высота", DescriptionHelp = "dfsfg"}, // new DescriptionItem {DescriptionName = "Ширина", DescriptionHelp = "dfsfg"}, // new DescriptionItem {DescriptionName = "Глубина", DescriptionHelp = "dfsfg"}, // new DescriptionItem {DescriptionName = "Вес", DescriptionHelp = "dfsfg"} //}; }
public async Task <IActionResult> Create([Bind("Name,Purpose,Id,Status")] Computer computer) { int.TryParse(Request.Form["data_storage"], out int DataStorage); int.TryParse(Request.Form["rams"], out int Ram); int.TryParse(Request.Form["processors"], out int Processor); int.TryParse(Request.Form["computer_case"], out int ComputerCase); int.TryParse(Request.Form["motherboards"], out int Motherboard); int.TryParse(Request.Form["gpus"], out int Gpu); int.TryParse(Request.Form["psus"], out int Psu); List <int> partIds = new List <int> { DataStorage, Ram, Processor, ComputerCase, Motherboard, Gpu, Psu }; var parts = _context.Part.Where(p => partIds.Contains(p.Id)); List <ComputerPart> computerParts = new List <ComputerPart>(); foreach (Part p in parts) { ComputerPart cp = new ComputerPart { Part = p, Computer = computer }; _context.ComputerPart.Add(cp); } if (ModelState.IsValid) { _context.Add(computer); await _context.SaveChangesAsync(); TempData["success"] = "Kompiuterio surinkimas sukurtas."; return(RedirectToAction(nameof(Index))); } return(View(computer)); }
//public ComputerPart cpu; public CPUDescriptionPage(ComputerPart item) { InitializeComponent(); this.BindingContext = item; //cpu = item; //tableView.BindingContext = item; //this.BindingContext = this; switch (item.WhoIs) { case computerParts.CASE: //item = (Case)item; break; case computerParts.CPU: //item = (CPU)item; break; case computerParts.HDD: break; case computerParts.MOTHERBOARD: break; case computerParts.POWERSUPPLY: break; case computerParts.RAM: break; case computerParts.VIDEOCARD: break; } }
public void DelComputerPartFromComputer(IList <ComputerPart> computerPartsSource, IList <ComputerPart> computerPartsDes, ComputerPart computerPart) { if (computerPartsDes.Contains(computerPart)) { computerPartsDes.Remove(computerPart); } }
public Reviews(ComputerPart item) { InitializeComponent(); }
public EditorWindow(ComputerPart computerPart) : this() { VM.ComputerPart = computerPart; }
public RAMDescriptionPage(ComputerPart item) { InitializeComponent(); }
public Ads(ComputerPart item) { InitializeComponent(); }
public MotherboardDescriptionPage(ComputerPart item) { InitializeComponent(); this.BindingContext = item; }
public ComputerHelper(Computer Computer) { DBContext = new computerAssemblyContext(); DataStorage = GetPartSelectList("data_storage"); Rams = GetPartSelectList("ram"); Processors = GetPartSelectList("processor"); ComputerCases = GetPartSelectList("computer_case"); Motherboards = GetPartSelectList("motherboard"); Gpus = GetPartSelectList("gpu"); Psus = GetPartSelectList("psu"); PcPurposes = new SelectList(new List <string> { "Mokslams", "Darbui", "Žaidimams", "Video/grafiniam kūrimui" }); // Setting default selected values for (int pTypeId = 1; pTypeId < 8; pTypeId++) { try { ComputerPart CPart = Computer.ComputerParts.Where(cp => cp.Part.PartTypeId == pTypeId).FirstOrDefault(); SelectList Parts = new SelectList(new List <string>()); switch (pTypeId) { case 1: Parts = DataStorage; break; case 2: Parts = Rams; break; case 3: Parts = Processors; break; case 4: Parts = ComputerCases; break; case 5: Parts = Motherboards; break; case 6: Parts = Gpus; break; case 7: Parts = Psus; break; } SetSelectedValue(Parts, CPart); } catch (ArgumentNullException e) { } catch (NullReferenceException e) { } catch (InvalidOperationException e) { } } }