public IList <InterventionType> GetInterventionTypes()
        {
            var repos = new InterventionTypeRepository(context);
            var list  = repos.GetAll();

            intType = list;
            return(list);
        }
        //validate the hours and cost required for the intervention with the max hours and max cost of Site Engineer
        private bool validateHoursCost()
        {
            var userRepo    = new UserRepository(context);
            var currentUser = userRepo.GetAllForUser(Utils.getInstance.GetCurrentUserId());
            var intTypeRepo = new InterventionTypeRepository(context);
            var intType     = intTypeRepo.GetInterventionTypeWithId(intervention.InterventionTypeId);

            if (currentUser.MaximumHours >= intervention.InterventionHours && currentUser.MaximumHours >= intType.InterventionTypeHours &&
                currentUser.MaximumCost >= intervention.InterventionCost && currentUser.MaximumCost >= intType.InterventionTypeCost)
            {
                return(true);
            }
            else
            {
                throw new EditStatusPermissionException();
            }
        }
Exemple #3
0
        private void CreateInterventionType()
        {
            var factory          = new DbConnectionFactory("CustomDatabase");
            var context          = new DbContext(factory);
            var repos            = new InterventionTypeRepository(context);
            var interventionType = new InterventionType();
            var rows             = repos.GetAll();

            if (rows.Count == 0)
            {
                interventionType.InterventionTypeName  = "Supply and Install Portable Toilet";
                interventionType.InterventionTypeHours = 10;
                interventionType.InterventionTypeCost  = 200;
                repos.Insert(interventionType);
                interventionType.InterventionTypeName  = "Hepatitis Avoidance Training";
                interventionType.InterventionTypeHours = 15;
                interventionType.InterventionTypeCost  = 300;
                repos.Insert(interventionType);
                interventionType.InterventionTypeName  = "Supply and Install Storm-proof Home Kit";
                interventionType.InterventionTypeHours = 50;
                interventionType.InterventionTypeCost  = 500;
                repos.Insert(interventionType);
            }
        }