Example #1
0
        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");
        }
Example #2
0
        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");
        }
Example #3
0
        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;
        }
Example #4
0
        private UserHub BindUserOwner(HubUserViewModel hubOwnerViewModel)
        {
            if (hubOwnerViewModel == null) return null;
            var hubOwner = new UserHub()
            {
               HubID = hubOwnerViewModel.HubID,
               UserProfileID = hubOwnerViewModel.UserProfileID,
               UserHubID = hubOwnerViewModel.UserHubID

            };
            return hubOwner;
        }