private void BindPage(string accessorySysNo) { if (!String.IsNullOrEmpty(accessorySysNo)) { _facade = new AccessoryFacade(); if (!int.TryParse(accessorySysNo, out _sysNo)) { Window.MessageBox.Show("配件编号无效.", MessageBoxType.Warning); return; } _facade.GetAccessoryBySysNo(int.Parse(accessorySysNo), (obj, args) => { if (args.FaultsHandle()) { return; } if (args.Result == null) { Window.MessageBox.Show("没有获得配件信息.", MessageBoxType.Warning); return; } var vm = args.Result.Convert <AccessoryInfo, AccessoryVM>(); DataContext = vm; }); } else { _sysNo = 0; DataContext = new AccessoryVM(); } }
public void RemoveBookAccessory(AccessoryVM acc) { var b = AnimalsBooked().SingleOrDefault(beast => beast.Accessory.Contains(acc)); var a = b.Accessory.First(accs => accs.ID == acc.ID); a.IsSelected = false; a.Selected = "Selecteren"; }
/// <summary> /// 转换配件视图和品牌实体 /// </summary> /// <param name="data"></param> /// <returns></returns> private AccessoryInfo CovertVMtoEntity(AccessoryVM data) { AccessoryInfo msg = data.ConvertVM <AccessoryVM, AccessoryInfo>((v, t) => { t.AccessoryName = new LanguageContent(v.AccessoryName); }); msg.SysNo = data.SysNo; return(msg); }
public ActionResult Edit([Bind(Include = "ID,Name,Price,BeastID")] AccessoryVM accessory) { if (ModelState.IsValid) { _accessRepo.UpdateAccessory(accessory); _accessRepo.Complete(); return(RedirectToAction("Index")); } ViewBag.BeastID = new SelectList(_accessRepo.ContextDB().Beast, "ID", "Name", accessory.BeastID); return(View(accessory)); }
// GET: Accessory/Details/5 public ActionResult Details(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var accessory = new AccessoryVM(_accessRepo.Get(id)); if (accessory == null) { return(HttpNotFound()); } return(View(accessory)); }
public ActionResult DeleteConfirmed(int id) { var accessory = new AccessoryVM(_accessRepo.Get(id)); var temp = accessory.Booking; foreach (var item in temp) { item.Accessory.Remove(accessory); } _boekingRepository.RecalculateTotalPrice(temp); _accessRepo.Remove(accessory.Accessory); _accessRepo.Complete(); return(RedirectToAction("Index")); }
// GET: Accessory/Edit/5 public ActionResult Edit(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var accessory = new AccessoryVM(_accessRepo.Get(id)); if (accessory == null) { return(HttpNotFound()); } ViewBag.BeastID = new SelectList(_accessRepo.ContextDB().Beast, "ID", "Name", accessory.BeastID); return(View(accessory)); }
public void EditAccessory_AccessoryIsUpdated_Test() { //1. Arrange _accessorycontroller = new AccessoryController(_accessoryRepository.Object, _boekingsRepository.Object); var Accessory = new AccessoryVM { Name = "Speelbal" }; //2. Act _accessorycontroller.Edit(Accessory); //3.Assert _accessoryRepository.Verify(b => b.UpdateAccessory(Accessory), Times.Once()); }
public void CreateAccessory_ReturnsAccessory_Test() { //1. Arrange _accessorycontroller = new AccessoryController(_accessoryRepository.Object, _boekingsRepository.Object); _accessorycontroller.ModelState.AddModelError("test", "test"); var Accessory = new AccessoryVM { ID = 1, Name = "Speelbal" }; _accessoryRepository.Setup(b => b.ContextDB()).Returns(new Domain.BeesteOpJeFeestjeEntities()); //2. Act var result = (ViewResult)_accessorycontroller.Create(Accessory); var SameAccessory = (AccessoryVM)result.ViewData.Model; //3.Assert Assert.AreEqual(Accessory.ID, SameAccessory.ID); }
public void DeleteConfirmed_RemovesAccessory_Test() { //1. Arrange _accessorycontroller = new AccessoryController(_accessoryRepository.Object, _boekingsRepository.Object); var Accessory = new AccessoryVM { ID = 1, Name = "Speelbal" }; _accessoryRepository.Setup(b => b.Get(Accessory.ID)).Returns(Accessory.Accessory); _accessoryRepository.Setup(b => b.ContextDB()).Returns(new BeesteOpJeFeestjeEntities()); //2. Act _accessorycontroller.DeleteConfirmed(Accessory.ID); //3.Assert _accessoryRepository.Verify(b => b.Remove(Accessory.Accessory), Times.Once()); }
public void IndexAccessory_ReturnsAccessoryList_Test() { //1. Arrange _accessorycontroller = new AccessoryController(_accessoryRepository.Object, _boekingsRepository.Object); var accessory = new AccessoryVM { ID = 1, Name = "Speelbal" }; var List = new List <Accessory>(); List.Add(accessory.Accessory); _accessoryRepository.Setup(b => b.GetAll()).Returns(List); //2. Act var result = (ViewResult)_accessorycontroller.Index(); var SameList = (List <AccessoryVM>)result.ViewData.Model; //3.Assert Assert.AreEqual(List[0], SameList[0].Accessory); }
public void EditAccessory_ReturnsInput_Test() { //1. Arrange _accessorycontroller = new AccessoryController(_accessoryRepository.Object, _boekingsRepository.Object); var Accessory = new AccessoryVM { ID = 1, Name = "Speelbal" }; _accessoryRepository.Setup(b => b.Get(Accessory.ID)).Returns(Accessory.Accessory); _accessoryRepository.Setup(b => b.ContextDB()).Returns(new Domain.BeesteOpJeFeestjeEntities()); //2. Act var result = (ViewResult)_accessorycontroller.Edit(Accessory.ID); var SameAccessory = (AccessoryVM)result.ViewData.Model; //3.Assert Assert.AreEqual(Accessory.ID, SameAccessory.ID); Assert.AreEqual(Accessory.Name, SameAccessory.Name); }
public ActionResult AddCheckedAccessory() { AccessoryVM accessory = null; var temp = _boekingRepository.TempBooking; var id = int.Parse(Request.Form.Get("AccID")); var accList = _boekingRepository.AccessoriesBooked().ToList(); //var acc = new AccessoryVM(_accrepo.Get(int.Parse(Request.Form.Get("AccID")))); foreach (var item in accList) { if (id == item.ID) { accessory = item; } } if (accessory == null) { accessory = new AccessoryVM(_accrepo.Get(id)); } if (accList.Contains(accessory)) { accessory.Selected = "Selecteren"; accessory.IsSelected = false; accList.Remove(accessory); temp.Accessory = accList; _boekingRepository.TempBooking = temp; InfoBar(); return(RedirectToAction("Step2")); } accessory.Selected = "Deselecteren"; accessory.IsSelected = true; accList.Add(accessory); temp.Accessory = accList; _boekingRepository.TempBooking = temp; InfoBar(); return(RedirectToAction("Step2")); }
/// <summary> /// 修改配件 /// </summary> /// <param name="data"></param> /// <param name="callback"></param> public void UpdateAccessory(AccessoryVM data, EventHandler <RestClientEventArgs <AccessoryInfo> > callback) { _restClient.Update(UPdateRelativeUrl, CovertVMtoEntity(data), callback); }
public void UpdateAccessory(AccessoryVM acc) { Context.Set <Accessory>().AddOrUpdate(acc.Accessory); }