public ActionResult Index(int page = FIRST_PAGE, string sortby = DEFAULT_SORT, string order = DEFAULT_DESC_ORDER) { if (!Authorized(RoleType.SystemManager)) { return(Error(Loc.Dic.error_no_permission)); } IEnumerable <Budgets_Baskets> permissions; using (BudgetsPermissionsRepository permissionsRep = new BudgetsPermissionsRepository()) { permissions = permissionsRep.GetList("Budgets_BasketsToAllocation").Where(x => x.CompanyId == CurrentUser.CompanyId); permissions = Pagination(permissions, page, sortby, order, true); return(View(permissions.ToList())); } }
public ActionResult BudgetBaskets(int id = 0, int page = FIRST_PAGE, string sortby = DEFAULT_SORT, string order = DEFAULT_DESC_ORDER) { if (!Authorized(RoleType.SystemManager)) return Error(Loc.Dic.error_no_permission); IEnumerable<Budgets_Baskets> baskets; Budgets_BasketsToAllocation per = new Budgets_BasketsToAllocation(); using (BudgetsRepository budgetsRep = new BudgetsRepository(CurrentUser.CompanyId)) using (BudgetsPermissionsRepository permissionsRep = new BudgetsPermissionsRepository()) { baskets = permissionsRep.GetList("Budgets_BasketsToAllocation").Where(x => x.CompanyId == CurrentUser.CompanyId); baskets = Pagination(baskets, page, sortby, order, true); ViewBag.budgetId = id; Budget budget = budgetsRep.GetList().SingleOrDefault(x => x.Id == id); ViewBag.budgetYear = budget.Year; ViewBag.budgetId = budget.Id; return View(baskets.ToList()); } }
public ActionResult BudgetBaskets(int id = 0, int page = FIRST_PAGE, string sortby = DEFAULT_SORT, string order = DEFAULT_DESC_ORDER) { if (!Authorized(RoleType.SystemManager)) { return(Error(Loc.Dic.error_no_permission)); } IEnumerable <Budgets_Baskets> baskets; Budgets_BasketsToAllocation per = new Budgets_BasketsToAllocation(); using (BudgetsRepository budgetsRep = new BudgetsRepository(CurrentUser.CompanyId)) using (BudgetsPermissionsRepository permissionsRep = new BudgetsPermissionsRepository()) { baskets = permissionsRep.GetList("Budgets_BasketsToAllocation").Where(x => x.CompanyId == CurrentUser.CompanyId); baskets = Pagination(baskets, page, sortby, order, true); ViewBag.budgetId = id; Budget budget = budgetsRep.GetList().SingleOrDefault(x => x.Id == id); ViewBag.budgetYear = budget.Year; ViewBag.budgetId = budget.Id; return(View(baskets.ToList())); } }
public ActionResult EditBaskets(int id = 0) { if (!Authorized(RoleType.SystemManager)) { return(Error(Loc.Dic.error_no_permission)); } UserPermissionsModel model = new UserPermissionsModel(); User user; List <Budgets_Baskets> allPermissions; using (UsersRepository usersRep = new UsersRepository(CurrentUser.CompanyId)) using (BudgetsPermissionsRepository permissionsRep = new BudgetsPermissionsRepository()) { user = usersRep.GetEntity(id); if (user == null) { return(Error(Loc.Dic.error_users_get_error)); } model.User = user; model.UserPermissions = user.Budgets_UsersToBaskets.Select(x => new UserPermission() { Permission = x.Budgets_Baskets, IsActive = true }).Where(x => x.Permission.CompanyId == CurrentUser.CompanyId).ToList(); if (model.UserPermissions == null) { return(Error(Loc.Dic.error_permissions_get_error)); } allPermissions = permissionsRep.GetList().Where(x => x.CompanyId == CurrentUser.CompanyId).ToList(); if (allPermissions == null) { return(Error(Loc.Dic.error_database_error)); } List <Budgets_Baskets> allWithoutUserBasket = new List <Budgets_Baskets>(); foreach (Budgets_Baskets basket in allPermissions) { allWithoutUserBasket.Add(basket); } foreach (UserPermission UserBasket in model.UserPermissions) { foreach (Budgets_Baskets basket in allPermissions) { if (UserBasket.Permission.Id == basket.Id) { allWithoutUserBasket.Remove(basket); } } } model.UserId = user.Id; model.PermissionsSelectList = new SelectList(allWithoutUserBasket, "Id", "Name"); return(View(model)); } }
public ActionResult Index(int page = FIRST_PAGE, string sortby = DEFAULT_SORT, string order = DEFAULT_DESC_ORDER) { if (!Authorized(RoleType.SystemManager)) return Error(Loc.Dic.error_no_permission); IEnumerable<Budgets_Baskets> permissions; using (BudgetsPermissionsRepository permissionsRep = new BudgetsPermissionsRepository()) { permissions = permissionsRep.GetList("Budgets_BasketsToAllocation").Where(x => x.CompanyId == CurrentUser.CompanyId); permissions = Pagination(permissions, page, sortby, order, true); return View(permissions.ToList()); } }
public ActionResult EditBaskets(int id = 0) { if (!Authorized(RoleType.SystemManager)) return Error(Loc.Dic.error_no_permission); UserPermissionsModel model = new UserPermissionsModel(); User user; List<Budgets_Baskets> allPermissions; using (UsersRepository usersRep = new UsersRepository(CurrentUser.CompanyId)) using (BudgetsPermissionsRepository permissionsRep = new BudgetsPermissionsRepository()) { user = usersRep.GetEntity(id); if (user == null) return Error(Loc.Dic.error_users_get_error); model.User = user; model.UserPermissions = user.Budgets_UsersToBaskets.Select(x => new UserPermission() { Permission = x.Budgets_Baskets, IsActive = true }).Where(x => x.Permission.CompanyId == CurrentUser.CompanyId).ToList(); if (model.UserPermissions == null) return Error(Loc.Dic.error_permissions_get_error); allPermissions = permissionsRep.GetList().Where(x => x.CompanyId == CurrentUser.CompanyId).ToList(); if (allPermissions == null) return Error(Loc.Dic.error_database_error); List<Budgets_Baskets> allWithoutUserBasket = new List<Budgets_Baskets>(); foreach (Budgets_Baskets basket in allPermissions) allWithoutUserBasket.Add(basket); foreach (UserPermission UserBasket in model.UserPermissions) foreach (Budgets_Baskets basket in allPermissions) if (UserBasket.Permission.Id == basket.Id) allWithoutUserBasket.Remove(basket); model.UserId = user.Id; model.PermissionsSelectList = new SelectList(allWithoutUserBasket, "Id", "Name"); return View(model); } }