Пример #1
0
        public ActionResult Create()
        {
            return(Error(Loc.Dic.Error_NoPermission));

            if (Authorized(RoleType.SystemManager))
            {
                using (BudgetsRepository budgetRep = new BudgetsRepository(CurrentUser.CompanyId))
                    using (BudgetsExpensesRepository expensesRep = new BudgetsExpensesRepository())
                        using (ParentProjectsRepository projectsRep = new ParentProjectsRepository())
                            using (SubProjectsRepository subProjectsRep = new SubProjectsRepository())
                            {
                                List <SelectListItemDB> budgetsList = budgetRep.GetList()
                                                                      .Where(budget => budget.CompanyId == CurrentUser.CompanyId && budget.Year >= (DateTime.Now.Year - 1))
                                                                      .Select(a => new { Id = a.Id, Name = a.Year })
                                                                      .AsEnumerable()
                                                                      .Select(x => new SelectListItemDB()
                                {
                                    Id = x.Id, Name = x.Name.ToString()
                                })
                                                                      .ToList();

                                List <SelectListItemDB> projectsList = projectsRep.GetList()
                                                                       .Where(project => project.CompanyId == CurrentUser.CompanyId && project.IsActive)
                                                                       .Select(x => new SelectListItemDB()
                                {
                                    Id = x.Id, Name = x.Name
                                })
                                                                       .ToList();

                                List <SelectListItemDB> subProjectsList = subProjectsRep.GetList()
                                                                          .Where(subProject => subProject.CompanyId == CurrentUser.CompanyId && subProject.IsActive)
                                                                          .Select(x => new SelectListItemDB()
                                {
                                    Id = x.Id, Name = x.Name
                                })
                                                                          .ToList();

                                ViewBag.BudgetId        = new SelectList(budgetsList, "Id", "Name");
                                ViewBag.ParentProjectId = new SelectList(projectsList, "Id", "Name");
                                ViewBag.SubProjectId    = new SelectList(subProjectsList, "Id", "Name");
                            }

                return(View());
            }
            else
            {
                return(Error(Loc.Dic.error_no_permission));
            }
        }
Пример #2
0
        public ActionResult Create()
        {
            return Error(Loc.Dic.Error_NoPermission);
            if (Authorized(RoleType.SystemManager))
            {
                using (BudgetsRepository budgetRep = new BudgetsRepository(CurrentUser.CompanyId))
                using (BudgetsExpensesRepository expensesRep = new BudgetsExpensesRepository())
                using (ParentProjectsRepository projectsRep = new ParentProjectsRepository())
                using (SubProjectsRepository subProjectsRep = new SubProjectsRepository())
                {
                    List<SelectListItemDB> budgetsList = budgetRep.GetList()
                        .Where(budget => budget.CompanyId == CurrentUser.CompanyId && budget.Year >= (DateTime.Now.Year - 1))
                        .Select(a => new { Id = a.Id, Name = a.Year })
                        .AsEnumerable()
                        .Select(x => new SelectListItemDB() { Id = x.Id, Name = x.Name.ToString() })
                        .ToList();

                    List<SelectListItemDB> projectsList = projectsRep.GetList()
                        .Where(project => project.CompanyId == CurrentUser.CompanyId && project.IsActive)
                        .Select(x => new SelectListItemDB() { Id = x.Id, Name = x.Name })
                        .ToList();

                    List<SelectListItemDB> subProjectsList = subProjectsRep.GetList()
                       .Where(subProject => subProject.CompanyId == CurrentUser.CompanyId && subProject.IsActive)
                       .Select(x => new SelectListItemDB() { Id = x.Id, Name = x.Name })
                       .ToList();

                    ViewBag.BudgetId = new SelectList(budgetsList, "Id", "Name");
                    ViewBag.ParentProjectId = new SelectList(projectsList, "Id", "Name");
                    ViewBag.SubProjectId = new SelectList(subProjectsList, "Id", "Name");
                }

                return View();
            }
            else
            {
                return Error(Loc.Dic.error_no_permission);
            }
        }
Пример #3
0
        public ActionResult Edit(int id = 0)
        {
            return Error(Loc.Dic.Error_NoPermission);
            if (Authorized(RoleType.SystemManager))
            {
                Budgets_Expenses expense;

                using (BudgetsExpensesRepository expensesRep = new BudgetsExpensesRepository())
                using (BudgetsRepository budgetRep = new BudgetsRepository(CurrentUser.CompanyId))
                using (ParentProjectsRepository projectsRep = new ParentProjectsRepository())
                using (SubProjectsRepository subProjectsRep = new SubProjectsRepository())
                {
                    expense = expensesRep.GetEntity(id);

                    if (expense != null)
                    {
                        if (expense.CompanyId == CurrentUser.CompanyId)
                        {
                            List<SelectListItemDB> budgetsList;
                            List<SelectListItemDB> projectsList;
                            List<SelectListItemDB> subProjectsList;

                            try
                            {
                                budgetsList = budgetRep.GetList()
                                    .Where(budget => budget.CompanyId == CurrentUser.CompanyId && budget.Year >= (DateTime.Now.Year - 1))
                                    .Select(a => new { Id = a.Id, Name = a.Year })
                                    .AsEnumerable()
                                    .Select(x => new SelectListItemDB() { Id = x.Id, Name = x.Name.ToString() })
                                    .ToList();

                                projectsList = projectsRep.GetList()
                                    .Where(type => type.CompanyId == CurrentUser.CompanyId)
                                    .Select(x => new SelectListItemDB() { Id = x.Id, Name = x.Name })
                                    .ToList();

                                subProjectsList = subProjectsRep.GetList()
                                   .Where(type => type.CompanyId == CurrentUser.CompanyId)
                                   .Select(x => new SelectListItemDB() { Id = x.Id, Name = x.Name })
                                   .ToList();
                            }
                            catch
                            {
                                return Error(Loc.Dic.error_database_error);
                            }

                            ViewBag.BudgetId = new SelectList(budgetsList, "Id", "Name", expense.BudgetId);
                            ViewBag.ParentProjectId = new SelectList(projectsList, "Id", "Name", expense.ParentProjectId);
                            ViewBag.SubProjectId = new SelectList(subProjectsList, "Id", "Name", expense.SubProjectId);

                            return View(expense);
                        }
                        else
                        {
                            return Error(Loc.Dic.error_no_permission);
                        }
                    }
                    else
                    {
                        return Error(Loc.Dic.error_income_get_error);
                    }
                }
            }
            else
            {
                return Error(Loc.Dic.error_no_permission);
            }
        }
Пример #4
0
        public ActionResult Edit(int id = 0)
        {
            return(Error(Loc.Dic.Error_NoPermission));

            if (Authorized(RoleType.SystemManager))
            {
                Budgets_Expenses expense;

                using (BudgetsExpensesRepository expensesRep = new BudgetsExpensesRepository())
                    using (BudgetsRepository budgetRep = new BudgetsRepository(CurrentUser.CompanyId))
                        using (ParentProjectsRepository projectsRep = new ParentProjectsRepository())
                            using (SubProjectsRepository subProjectsRep = new SubProjectsRepository())
                            {
                                expense = expensesRep.GetEntity(id);

                                if (expense != null)
                                {
                                    if (expense.CompanyId == CurrentUser.CompanyId)
                                    {
                                        List <SelectListItemDB> budgetsList;
                                        List <SelectListItemDB> projectsList;
                                        List <SelectListItemDB> subProjectsList;

                                        try
                                        {
                                            budgetsList = budgetRep.GetList()
                                                          .Where(budget => budget.CompanyId == CurrentUser.CompanyId && budget.Year >= (DateTime.Now.Year - 1))
                                                          .Select(a => new { Id = a.Id, Name = a.Year })
                                                          .AsEnumerable()
                                                          .Select(x => new SelectListItemDB()
                                            {
                                                Id = x.Id, Name = x.Name.ToString()
                                            })
                                                          .ToList();

                                            projectsList = projectsRep.GetList()
                                                           .Where(type => type.CompanyId == CurrentUser.CompanyId)
                                                           .Select(x => new SelectListItemDB()
                                            {
                                                Id = x.Id, Name = x.Name
                                            })
                                                           .ToList();

                                            subProjectsList = subProjectsRep.GetList()
                                                              .Where(type => type.CompanyId == CurrentUser.CompanyId)
                                                              .Select(x => new SelectListItemDB()
                                            {
                                                Id = x.Id, Name = x.Name
                                            })
                                                              .ToList();
                                        }
                                        catch
                                        {
                                            return(Error(Loc.Dic.error_database_error));
                                        }

                                        ViewBag.BudgetId        = new SelectList(budgetsList, "Id", "Name", expense.BudgetId);
                                        ViewBag.ParentProjectId = new SelectList(projectsList, "Id", "Name", expense.ParentProjectId);
                                        ViewBag.SubProjectId    = new SelectList(subProjectsList, "Id", "Name", expense.SubProjectId);

                                        return(View(expense));
                                    }
                                    else
                                    {
                                        return(Error(Loc.Dic.error_no_permission));
                                    }
                                }
                                else
                                {
                                    return(Error(Loc.Dic.error_income_get_error));
                                }
                            }
            }
            else
            {
                return(Error(Loc.Dic.error_no_permission));
            }
        }