Ejemplo n.º 1
0
        public static void Create(BudgetVM model, BPARepo bpaRepo)
        {
            var budget = new Budget()
            {
                BudgetName     = model.BudgetName,
                BudgetAmount   = model.BudgetAmount,
                DepartmentId   = model.DepartmentId,
                ProgramId      = model.ProgramId,
                ActivityId     = model.ActivityId,
                BudgetPeriodId = model.BudgetPeriodId,
                Months         = model.Months,
                StartDate      = model.StartDate,
                EndDate        = model.EndDate,
            };

            budget.Validate();
            var exist = bpaRepo.Budget.GetAll().Any(x => x.BudgetName.Trim().ToLower() == budget.BudgetName.Trim().ToLower());

            if (!exist)
            {
                bpaRepo.Budget.Create(budget);
            }
            else
            {
                throw new Exception($"{model.BudgetName} already exist");
            }
        }
 internal static ExpenseVM GetNew(BPARepo bpaRepo, int budgetId)
 {
     return(new ExpenseVM()
     {
         BudgetId = budgetId,
     });
 }
        public static ExpensesVM GetAll(BPARepo bpaRepo, int budgetId)
        {
            var expenses = bpaRepo.Expense.GetAll().Where(x => x.BudgetId == budgetId).ToList();
            var expenseVMs = new List<ExpenseVM>();

            foreach (var expense in expenses)
            {
                var expenseVM = new ExpenseVM()
                {
                    Id = expense.Id,
                    BudgetId = expense.BudgetId,
                    ExpenseName = expense.ExpenseName,
                    ExpenseAmount = expense.ExpenseAmount,
                    Units = expense.Units,
                    ExpenseDate = expense.ExpenseDate,
                };
                expenseVMs.Add(expenseVM);
            }
            var model = new ExpensesVM()
            {
                Expenses = expenseVMs,
                BudgetId = budgetId,
            };
            return model;
        }
Ejemplo n.º 4
0
        internal static void Update(BudgetVM model, BPARepo bpaRepo)
        {
            var budget = bpaRepo.Budget.GetById(model.Id);

            budget.BudgetName     = model.BudgetName;
            budget.BudgetAmount   = model.BudgetAmount;
            budget.DepartmentId   = model.BudgetAmount;
            budget.ProgramId      = model.ProgramId;
            budget.ActivityId     = model.ActivityId;
            budget.BudgetPeriodId = model.BudgetPeriodId;
            budget.Months         = model.Months;
            budget.StartDate      = model.StartDate;
            budget.EndDate        = model.EndDate;

            budget.Validate();
            var exist = bpaRepo.Budget.GetAll().Any(x => x.BudgetName.Trim().ToLower() == budget.BudgetName.Trim().ToLower() &&
                                                    x.Id != budget.Id);

            if (!exist)
            {
                bpaRepo.Budget.Update(budget);
            }
            else
            {
                throw new Exception($"{model.BudgetName} already exist");
            }
        }
        public static List <BudgetExpenseVM> GetAll(BPARepo bpaRepo)
        {
            var budgetExpenses = bpaRepo.Budget.GetAll().ToList();
            var model          = new List <BudgetExpenseVM>();

            foreach (var budgetExpense in budgetExpenses)
            {
                var budgetExpenseVM = new BudgetExpenseVM()
                {
                    Id             = budgetExpense.Id,
                    BudgetName     = budgetExpense.BudgetName,
                    BudgetAmount   = budgetExpense.BudgetAmount,
                    DepartmentId   = budgetExpense.DepartmentId,
                    ProgramId      = budgetExpense.ProgramId,
                    ActivityId     = budgetExpense.ActivityId,
                    BudgetPeriodId = budgetExpense.BudgetPeriodId,
                    Months         = budgetExpense.Months,
                    StartDate      = budgetExpense.StartDate,
                    EndDate        = budgetExpense.EndDate,
                };
                model.Add(budgetExpenseVM);
            }

            return(model);
        }
Ejemplo n.º 6
0
        public static BudgetPeriodVM GetById(int id, BPARepo bpaRepo)
        {
            var budgetPeriod = bpaRepo.BudgetPeriod.GetById(id);
            var model        = new BudgetPeriodVM()
            {
                Id   = budgetPeriod.Id,
                Name = budgetPeriod.Name,
            };

            return(model);
        }
Ejemplo n.º 7
0
        public static DepartmentVM GetById(int id, BPARepo bpaRepo)
        {
            var department = bpaRepo.Department.GetById(id);
            var model      = new DepartmentVM()
            {
                Id       = department.Id,
                Name     = department.Name,
                Created  = department.Created,
                Modified = department.Modified,
            };

            return(model);
        }
        public static ProgramVM GetById(int id, BPARepo bpaRepo)
        {
            var program = bpaRepo.Program.GetById(id);
            var model   = new ProgramVM()
            {
                Id       = program.Id,
                Name     = program.Name,
                Created  = program.Created,
                Modified = program.Modified,
            };

            return(model);
        }
Ejemplo n.º 9
0
        public static ActivityVM GetById(int id, BPARepo bpaRepo)
        {
            var activity = bpaRepo.Activities.GetById(id);
            var model    = new ActivityVM()
            {
                Id        = activity.Id,
                Name      = activity.Name,
                ManagerId = activity.ManagerId,
                Objective = activity.Objective,
            };

            return(model);
        }
        public static MissionVM GetById(int id, BPARepo bpaRepo)
        {
            var mission = bpaRepo.Mission.GetById(id);
            var model   = new MissionVM()
            {
                Id       = mission.Id,
                Name     = mission.Name,
                Created  = mission.Created,
                Modified = mission.Modified,
            };

            return(model);
        }
        //public static SelectList GetRoles()
        //{
        //    var roles = CreateFromEnumStrings<RolesEnum>();
        //    return roles;
        //}

        public static SelectList GetMission()
        {
            BPARepo repo     = new BPARepo();
            var     missions = new List <Mission>();
            var     mission  = new Mission()
            {
                Id   = 0,
                Name = "Please Select",
            };

            missions.Add(mission);
            missions.AddRange(repo.Mission.GetAll().ToList());

            return(CreateSelectList(missions, x => x.Id, x => x.Name));
        }
 protected override void Initialize(RequestContext requestContext)
 {
     try
     {
         base.Initialize(requestContext);
         if (BPARepo == null)
         {
             BPARepo = new BPARepo();
         }
     }
     catch (Exception ex)
     {
         var msg = ex.Message;
     }
 }
        public static SelectList GetDepartment()
        {
            BPARepo repo        = new BPARepo();
            var     departments = new List <Department>();
            var     department  = new Department()
            {
                Id   = 0,
                Name = "Please Select",
            };

            departments.Add(department);
            departments.AddRange(repo.Department.GetAll().ToList());

            return(CreateSelectList(departments, x => x.Id, x => x.Name));
        }
        public static SelectList GetEmployee()
        {
            BPARepo repo      = new BPARepo();
            var     employees = new List <Employee>();
            var     employee  = new Employee()
            {
                Id           = 0,
                EmployeeName = "Please Select",
            };

            employees.Add(employee);
            employees.AddRange(repo.Employee.GetAll().ToList());

            return(CreateSelectList(employees, x => x.Id, x => x.EmployeeName));
        }
        public static ExpenseVM GetById(int id, BPARepo bpaRepo)
        {
            var expense = bpaRepo.Expense.GetById(id);
            var model   = new ExpenseVM()
            {
                Id            = expense.Id,
                BudgetId      = expense.BudgetId,
                ExpenseName   = expense.ExpenseName,
                ExpenseAmount = expense.ExpenseAmount,
                Units         = expense.Units,
                ExpenseDate   = expense.ExpenseDate,
            };

            return(model);
        }
        public static SelectList GetBudget()
        {
            BPARepo repo    = new BPARepo();
            var     budgets = new List <Budget>();
            var     budget  = new Budget()
            {
                Id         = 0,
                BudgetName = "Please Select",
            };

            budgets.Add(budget);
            budgets.AddRange(repo.Budget.GetAll().ToList());

            return(CreateSelectList(budgets, x => x.Id, x => x.BudgetName));
        }
        public static SelectList GetBudgetPeriod()
        {
            BPARepo repo          = new BPARepo();
            var     budgetPeriods = new List <BudgetPeriod>();
            var     budgetPeriod  = new BudgetPeriod()
            {
                Id   = 0,
                Name = "Please Select",
            };

            budgetPeriods.Add(budgetPeriod);
            budgetPeriods.AddRange(repo.BudgetPeriod.GetAll().ToList());

            return(CreateSelectList(budgetPeriods, x => x.Id, x => x.Name));
        }
        public static SelectList GetActivity()
        {
            BPARepo repo       = new BPARepo();
            var     activities = new List <Activities>();
            var     activity   = new Activities()
            {
                Id   = 0,
                Name = "Please Select",
            };

            activities.Add(activity);
            activities.AddRange(repo.Activities.GetAll().ToList());

            return(CreateSelectList(activities, x => x.Id, x => x.Name));
        }
        public static SelectList GetProgram()
        {
            BPARepo repo     = new BPARepo();
            var     programs = new List <Program>();
            var     program  = new Program()
            {
                Id   = 0,
                Name = "Please Select",
            };

            programs.Add(program);
            programs.AddRange(repo.Program.GetAll().ToList());

            return(CreateSelectList(programs, x => x.Id, x => x.Name));
        }
Ejemplo n.º 20
0
        public static List <BudgetPeriodVM> GetAll(BPARepo bpaRepo)
        {
            var budgetPeriods = bpaRepo.BudgetPeriod.GetAll().ToList();
            var model         = new List <BudgetPeriodVM>();

            foreach (var budgetPeriod in budgetPeriods)
            {
                var budgetPeriodVM = new BudgetPeriodVM()
                {
                    Id   = budgetPeriod.Id,
                    Name = budgetPeriod.Name,
                };
                model.Add(budgetPeriodVM);
            }

            return(model);
        }
Ejemplo n.º 21
0
        internal static void Update(BudgetPeriodVM model, BPARepo bpaRepo)
        {
            var budgetPeriod = bpaRepo.BudgetPeriod.GetById(model.Id);

            budgetPeriod.Name = model.Name;

            budgetPeriod.Validate();
            var exist = bpaRepo.BudgetPeriod.GetAll().Any(x => x.Name.Trim().ToLower() == budgetPeriod.Name.Trim().ToLower() &&
                                                          x.Id != budgetPeriod.Id);

            if (!exist)
            {
                bpaRepo.BudgetPeriod.Update(budgetPeriod);
            }
            else
            {
                throw new Exception($"{model.Name} already exist");
            }
        }
Ejemplo n.º 22
0
        public static void Create(BudgetPeriodVM model, BPARepo bpaRepo)
        {
            var budgetPeriod = new BudgetPeriod()
            {
                Name = model.Name,
            };

            budgetPeriod.Validate();
            var exist = bpaRepo.BudgetPeriod.GetAll().Any(x => x.Name.Trim().ToLower() == budgetPeriod.Name.Trim().ToLower());

            if (!exist)
            {
                bpaRepo.BudgetPeriod.Create(budgetPeriod);
            }
            else
            {
                throw new Exception($"{model.Name} already exist");
            }
        }
        public static List <ProgramVM> GetAll(BPARepo bpaRepo)
        {
            var programs = bpaRepo.Program.GetAll().ToList();
            var model    = new List <ProgramVM>();

            foreach (var program in programs)
            {
                var programVM = new ProgramVM()
                {
                    Id       = program.Id,
                    Name     = program.Name,
                    Created  = program.Created,
                    Modified = program.Modified,
                };
                model.Add(programVM);
            }

            return(model);
        }
Ejemplo n.º 24
0
        public static List <DepartmentVM> GetAll(BPARepo bpaRepo)
        {
            var departments = bpaRepo.Department.GetAll().ToList();
            var model       = new List <DepartmentVM>();

            foreach (var department in departments)
            {
                var departmentVM = new DepartmentVM()
                {
                    Id       = department.Id,
                    Name     = department.Name,
                    Created  = department.Created,
                    Modified = department.Modified,
                };
                model.Add(departmentVM);
            }

            return(model);
        }
Ejemplo n.º 25
0
        public static BudgetVM GetById(int id, BPARepo bpaRepo)
        {
            var budget = bpaRepo.Budget.GetById(id);
            var model  = new BudgetVM()
            {
                Id             = budget.Id,
                BudgetName     = budget.BudgetName,
                BudgetAmount   = budget.BudgetAmount,
                DepartmentId   = budget.DepartmentId,
                ProgramId      = budget.ProgramId,
                ActivityId     = budget.ActivityId,
                BudgetPeriodId = budget.BudgetPeriodId,
                Months         = budget.Months,
                StartDate      = budget.StartDate,
                EndDate        = budget.EndDate,
            };

            return(model);
        }
        public static List <MissionVM> GetAll(BPARepo bpaRepo)
        {
            var missions = bpaRepo.Mission.GetAll().ToList();
            var model    = new List <MissionVM>();

            foreach (var mission in missions)
            {
                var missionVM = new MissionVM()
                {
                    Id       = mission.Id,
                    Name     = mission.Name,
                    Created  = mission.Created,
                    Modified = mission.Modified,
                };
                model.Add(missionVM);
            }

            return(model);
        }
Ejemplo n.º 27
0
        public static List <ActivityVM> GetAll(BPARepo bpaRepo)
        {
            var activities = bpaRepo.Activities.GetAll().ToList();
            var model      = new List <ActivityVM>();

            foreach (var activity in activities)
            {
                var activityVM = new ActivityVM()
                {
                    Id        = activity.Id,
                    Name      = activity.Name,
                    ManagerId = activity.ManagerId,
                    Objective = activity.Objective,
                };
                model.Add(activityVM);
            }

            return(model);
        }
Ejemplo n.º 28
0
        internal static void Update(DepartmentVM model, BPARepo bpaRepo)
        {
            var department = bpaRepo.Department.GetById(model.Id);

            department.Name     = model.Name;
            department.Modified = DateTime.Now;

            department.Validate();
            var exist = bpaRepo.Department.GetAll().Any(x => x.Name.Trim().ToLower() == department.Name.Trim().ToLower() &&
                                                        x.Id != department.Id);

            if (!exist)
            {
                bpaRepo.Department.Update(department);
            }
            else
            {
                throw new Exception($"{model.Name} already exist");
            }
        }
        internal static void Update(MissionVM model, BPARepo bpaRepo)
        {
            var mission = bpaRepo.Mission.GetById(model.Id);

            mission.Name     = model.Name;
            mission.Modified = DateTime.Now;

            mission.Validate();
            var exist = bpaRepo.Mission.GetAll().Any(x => x.Name.Trim().ToLower() == mission.Name.Trim().ToLower() &&
                                                     x.Id != mission.Id);

            if (!exist)
            {
                bpaRepo.Mission.Update(mission);
            }
            else
            {
                throw new Exception($"{model.Name} already exist");
            }
        }
        internal static void Update(ProgramVM model, BPARepo bpaRepo)
        {
            var program = bpaRepo.Program.GetById(model.Id);

            program.Name     = model.Name;
            program.Modified = DateTime.Now;

            program.Validate();
            var exist = bpaRepo.Program.GetAll().Any(x => x.Name.Trim().ToLower() == program.Name.Trim().ToLower() &&
                                                     x.Id != program.Id);

            if (!exist)
            {
                bpaRepo.Program.Update(program);
            }
            else
            {
                throw new Exception($"{model.Name} already exist");
            }
        }