Exemple #1
0
 public bool DeleteUserHub(UserHub entity)
 {
     if (entity == null) return false;
     _unitOfWork.UserHubRepository.Delete(entity);
     _unitOfWork.Save();
     return true;
 }
        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);
        }
Exemple #3
0
 public void AddUserHub(int warehouseID, int userID)
 {
     UserProfile uProfile = _unitOfWork.UserProfileRepository.Get(t=>t.UserProfileID==userID,null,"UserHubs").FirstOrDefault();
     if (uProfile != null)
     {
         var associations = from v in uProfile.UserHubs
                            where v.HubID == warehouseID
                            select v;
         if (!associations.Any())
         {
             var userHub = new UserHub
                               {
                                   UserProfileID = uProfile.UserProfileID,
                                   HubID = warehouseID,
                                   IsDefault = "1"
                               };
             AddUserHub(userHub);
         }
     }
 }
Exemple #4
0
 public bool EditUserHub(UserHub entity)
 {
     _unitOfWork.UserHubRepository.Edit(entity);
     _unitOfWork.Save();
     return true;
 }
Exemple #5
0
 public bool AddUserHub(UserHub entity)
 {
     _unitOfWork.UserHubRepository.Add(entity);
     _unitOfWork.Save();
     return true;
 }
 public ActionResult Edit(UserHub userwarehouse)
 {
     if (ModelState.IsValid)
     {
         _userHubService.EditUserHub(userwarehouse);
         //db.UserHubs.Attach(userwarehouse);
         //db.ObjectStateManager.ChangeObjectState(userwarehouse, EntityState.Modified);
         ////if (userwarehouse.IsDefault == "1")
         ////{
         ////    var uProfile = userwarehouse.UserProfile;
         ////    uProfile.ChangeWarehouse(userwarehouse.UserWarehouseID);
         ////}
         //db.SaveChanges();
         //return RedirectToAction("Index");
         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 View(userwarehouse);
 }