public ActionResult Delete(string[] cbxItem)
        {
            qtUnitManagerService _managerservice = new qtUnitManagerService();

            foreach (var item in cbxItem)
            {
                List <qtUnitManager> list = _managerservice.FindList().Where(m => m.UserId == TypeHelper.ToInt32(item)).ToList();
                if (list.Count() > 0)
                {
                    foreach (qtUnitManager unit in list)
                    {
                        _managerservice.Delete(unit.UnitManagerId);
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
        public string checkUnit(int?userId, int?unitId)
        {
            qtUnitManagerService _managerservice = new qtUnitManagerService();
            string check = string.Empty;

            if (!userId.HasValue || !unitId.HasValue)
            {
                return(check);
            }
            qtUnitManager list = _managerservice.FindList().AsQueryable()
                                 .Where(u => u.UnitId == unitId && u.UserId == userId && u.Active == true)
                                 .FirstOrDefault();

            if (list != null)
            {
                return("checked='checked'");
            }
            return(check);
        }
        public ActionResult Create(int?User, string[] cbxUnit)
        {
            qtUnitManagerService _managerservice = new qtUnitManagerService();

            if (cbxUnit.Length > 0 && cbxUnit.ToString() != "" && cbxUnit[0] != "")
            {
                List <qtUnitManager> list = _managerservice.FindList().Where(u => u.UserId == User).ToList();
                foreach (qtUnitManager unit in list)
                {
                    _managerservice.Delete(unit);
                }
                foreach (string item in cbxUnit)
                {
                    qtUnitManager manager = new qtUnitManager();
                    manager.UserId = User;
                    manager.UnitId = TypeHelper.ToInt32(item);
                    manager.Active = true;
                    _managerservice.Insert(manager);
                }
            }
            return(RedirectToAction("Index"));
        }