Пример #1
0
        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);
        }
Пример #2
0
        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"));
        }