public void AddModuleInDepartment(List<ModuleInDepartment> moduleInDepartment) { using (var uow = new UnitOfWork()) { if (moduleInDepartment.IsCollectionValid()) { moduleInDepartment.Each(x => { var moduleInDept = uow.GetRepository<ModuleInDepartment>().Items.Where(y => y.ModuleId == x.ModuleId).ToList(); if (!moduleInDept.IsCollectionValid()) uow.GetRepository<ModuleInDepartment>().Insert(x); }); uow.SaveChanges(); } } }
private void ValidateUserLoginDetails(List<UserLoginViewModel> userLoginViewModel) { if (userLoginViewModel.IsCollectionValid()) { userLoginViewModel.ForEach(x => { if (x.Password.IsNull() || x.Password.IsEmpty()) ModelState.AddModelError("Password", "Password is mandatory."); if (x.SecurityAnswer.IsNull() || x.SecurityAnswer.IsEmpty()) ModelState.AddModelError("SecurityAnswer", "Security Answer is mandatory."); }); } }
public List<Module> GetAllModule(long departmentId) { using (var uow = new UnitOfWork()) { var moduleList = new List<Module>(); if (departmentId != 0) { moduleList = uow.GetRepository<Module>().Items.Where(x => x.DepartmentId == departmentId).ToList(); if (!moduleList.IsCollectionValid()) { var modules = uow.GetRepository<Module>().Items.Where(x => x.DepartmentId == null).ToList(); foreach (var mod in modules) { moduleList.Add(mod); } } } return moduleList; } }