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 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")); }