public void CanDoPostBackEdit() { //ACT var store = new Store { Name = "Store 4", HubID = 2, IsActive = true, IsTemporary = false, Number = 101, StackCount = 1, StoreManName = "Mezgebu" }; var result = _storeController.Edit(store); //Assert Assert.IsInstanceOf<ActionResult>(result); Assert.IsInstanceOf<int>(store.StoreID); }
public virtual ActionResult Create(Store store) { if (ModelState.IsValid) { _storService.AddStore(store); return Json(new { success = true }); } BLL.UserProfile user = _userProfileService.GetUser(User.Identity.Name); ViewBag.HubID = new SelectList(user.UserAllowedHubs.OrderBy(p => p.Name), "HubID", "HubNameWithOwner"); return PartialView(store); }
// // GET: /Store/Edit/5 public virtual ActionResult Edit(int id) { BLL.UserProfile user = _userProfileService.GetUser(User.Identity.Name); var stores = _storService.GetAllByHUbs(user.UserAllowedHubs); Store store = stores.Find(p => p.StoreID == id);//only look inside the allowed stores if (store != null){ ViewBag.HubID = new SelectList(user.UserAllowedHubs.OrderBy(p => p.Name), "HubID", "HubNameWithOwner", store.HubID); } else { store = new Store(); ViewBag.HubID = new SelectList(Enumerable.Empty<SelectListItem>()); } return PartialView(store); }