public void CanCreateUserWarehouse() { var request = new DataSourceRequest(); var userWarehouseViewModel = new HubUserViewModel { UserHubID = 2, HubID = 1, UserProfileID = 2, IsDefault = "False" }; var result = _userWarehouseController.Create(request,userWarehouseViewModel); Assert.IsInstanceOf<JsonResult>(result); }
public ActionResult HubOwnerDestroy([DataSourceRequest] DataSourceRequest request, HubUserViewModel userhub) { if (userhub != null && ModelState.IsValid) { var result = _userHubService.FindById(userhub.UserHubID); if (result != null) { _userHubService.DeleteUserHub(result); } } return Json(ModelState.ToDataSourceResult()); }
public ActionResult Edit([DataSourceRequest] DataSourceRequest request,HubUserViewModel userwarehouse) { if (ModelState.IsValid) { _userHubService.EditUserHub(BindUserOwner(userwarehouse)); return Json(new { success = true }); } ViewBag.UserProfileID = new SelectList(_userProfileService.GetAllUserProfile(), "UserProfileID", "UserName", userwarehouse.UserProfileID); ViewBag.WarehouseID = new SelectList(_hubService.GetAllHub(), "HubID", "Name", userwarehouse.HubID); return RedirectToAction("index"); }
public ActionResult Create([DataSourceRequest] DataSourceRequest request ,HubUserViewModel userwarehouse) { if (ModelState.IsValid && userwarehouse!=null) { _userHubService.AddUserHub(BindUserOwner(userwarehouse)); return Json(new [] { userwarehouse }.ToDataSourceResult(request, ModelState)); } ViewBag.UserProfileID = new SelectList(_userProfileService.GetAllUserProfile(), "UserProfileID", "UserName", userwarehouse.UserProfileID); ViewBag.WarehouseID = new SelectList(_hubService.GetAllHub(), "HubID", "Name", userwarehouse.HubID); return RedirectToAction("index"); }
public ActionResult HubOwnerUpdate([DataSourceRequest] DataSourceRequest request, HubUserViewModel userhub) { if (userhub != null && ModelState.IsValid) { UserHub result = _userHubService.FindById(userhub.UserHubID); if (result != null) { result.UserProfileID = userhub.UserProfileID; result.HubID = userhub.HubID; _userHubService.EditUserHub(result); } } return Json(new[] { userhub }.ToDataSourceResult(request, ModelState)); }
private IEnumerable<HubUserViewModel> GetUserHub() { var result = _userHubService.GetAllUserHub(); var viewModelList = new List<HubUserViewModel>(); foreach (var hubOwner in result) { var ownerViewModel = new HubUserViewModel(); ownerViewModel.HubID = hubOwner.HubID; ownerViewModel.UserHubID = hubOwner.UserHubID; ownerViewModel.UserProfileID = hubOwner.UserProfileID; viewModelList.Add(ownerViewModel); } return viewModelList; }
private UserHub BindUserOwner(HubUserViewModel hubOwnerViewModel) { if (hubOwnerViewModel == null) return null; var hubOwner = new UserHub() { HubID = hubOwnerViewModel.HubID, UserProfileID = hubOwnerViewModel.UserProfileID, }; return hubOwner; }
public ActionResult UserHubCreate([DataSourceRequest] DataSourceRequest request, HubUserViewModel userhub) { if (userhub != null && ModelState.IsValid) { var result = BindUserOwner(userhub); //int userProfileId = result.UserProfileID; //int wareHouseId= result.UserHubID; _userHubService.AddUserHub(result); } return Json(new[] { userhub }.ToDataSourceResult(request, ModelState)); }