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))); }
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 Create(UserHub userwarehouse) { if (ModelState.IsValid) { _userHubService.AddUserHub(userwarehouse); //if (userwarehouse.IsDefault == "1") //{ // var uProfile = userwarehouse.UserProfile; // uProfile.ChangeWarehouse(userwarehouse.UserWarehouseID); //} //return Json(new { success = true }); return(RedirectToAction("Index")); } ViewBag.UserProfileID = new SelectList(_userProfileService.GetAllUserProfile(), "UserProfileID", "UserName", userwarehouse.UserProfileID); ViewBag.WarehouseID = new SelectList(_hubService.GetAllHub(), "HubID", "Name", userwarehouse.HubID); return(View(userwarehouse)); }
public virtual ActionResult UserHubs(FormCollection userHubs) { var hubModel = Session["Hubs"] as UserHubsModel; var userName = Session["UserName"].ToString(); if (hubModel != null) { for (var i = 0; i < hubModel.UserHubs.Count(); i++) { var model = new UserHubModel { HubID = hubModel.UserHubs[i].HubID, Name = hubModel.UserHubs[i].Name }; model.Selected = userHubs.GetValue(string.Format("[{0}].Selected", model.HubID)).AttemptedValue.Contains("true"); if (model.Selected == hubModel.UserHubs[i].Selected) { continue; } var userID = (from v in _userProfileService.GetAllUserProfile() where v.UserName == userName select v.UserProfileID).FirstOrDefault(); var hub = new Hub(); if (model.Selected) { _userHubService.AddUserHub(model.HubID, userID); } else { _userHubService.RemoveUserHub(model.HubID, userID); } } } return(Json(new { success = true })); }