Esempio n. 1
0
        public Employee GetSpecificEmployee(int employeeId)
        {
            Employee employee;

            var dbContext = new SDIIS_DatabaseEntities();

            try
            {
                var employees = (from e in dbContext.Employees
                                 where e.Employee_Id.Equals(employeeId)
                                 select e).ToList();

                //agent = PopulateAdditionalItems(agents, dbContext).FirstOrDefault();

                employee = (from e in employees
                            select e).FirstOrDefault();
            }
            catch (Exception ex)
            {
                return(null);
            }

            return(employee);
        }
Esempio n. 2
0
        public List <Role> GetListOfRoles(bool showInactive, bool showDeleted)
        {
            List <Role> listOfRoles;

            using (var dbContext = new SDIIS_DatabaseEntities())
            {
                try
                {
                    var roles = (from r in dbContext.Roles
                                 where r.Is_Active.Equals(true) || r.Is_Active.Equals(!showInactive)
                                 where r.Is_Deleted.Equals(false) || r.Is_Deleted.Equals(showDeleted)
                                 select r).ToList();

                    listOfRoles = (from r in roles
                                   select r).ToList();
                }
                catch (Exception ex)
                {
                    return(null);
                }
            }

            return(listOfRoles);
        }
Esempio n. 3
0
        public List <Group> GetListOfGroups(bool showInActive, bool showDeleted)
        {
            List <Group> groups;

            using (var dbContext = new SDIIS_DatabaseEntities())
            {
                try
                {
                    var groupsList = (from g in dbContext.Groups
                                      where g.Is_Active.Equals(true) || g.Is_Active.Equals(!showInActive)
                                      where g.Is_Deleted.Equals(false) || g.Is_Deleted.Equals(showDeleted)
                                      select g).ToList();

                    groups = (from g in groupsList
                              select g).ToList();
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            return(groups);
        }
Esempio n. 4
0
        public Module CreateModule(string description, string baseUrl, bool isActive)
        {
            Module newModule;

            var dbContext = new SDIIS_DatabaseEntities();

            var module = new Module()
            {
                Description = description, Base_URL = baseUrl, Is_Active = isActive, Is_Deleted = false, Date_Created = DateTime.Now
            };

            try
            {
                newModule = dbContext.Modules.Add(module);

                dbContext.SaveChanges();
            }
            catch (Exception)
            {
                newModule = null;
            }

            return(newModule);
        }
Esempio n. 5
0
        public List <Menu> GetListOfMenus(bool showInActive, bool showDeleted)
        {
            List <Menu> menus;

            using (var dbContext = new SDIIS_DatabaseEntities())
            {
                try
                {
                    var menusList = (from m in dbContext.Menus
                                     where m.Is_Active.Equals(true) || m.Is_Active.Equals(!showInActive)
                                     where m.Is_Deleted.Equals(false) || m.Is_Deleted.Equals(showDeleted)
                                     select m).ToList();

                    menus = (from menu in menusList
                             select menu).ToList();
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            return(menus);
        }
Esempio n. 6
0
        private IEnumerable <Menu_Item> PopulateAdditionalItems(IEnumerable <Menu_Item> listOfMenuItems, SDIIS_DatabaseEntities dbContext)
        {
            var populatedMenuItems = new List <Menu_Item>();

            populatedMenuItems = (from a in listOfMenuItems
                                  select a.Set(a1 =>
            {
                a1.Module_Action_Id = a.Module_Action == null ? null : (int?)a.Module_Action.Module_Action_Id;
                a1.Module_Controller_Id = a.Module_Action == null ? null : (int?)a.Module_Action.Module_Controller_Id;
            })).ToList();

            return(populatedMenuItems);
        }
Esempio n. 7
0
        public Employee CreateEmployee(string firstName, string lastName, string persalNumber, int?headOfDepartmentId, int?supervisorId, string phoneNumber, string mobilePhoneNumber,
                                       int?genderId, int?raceId, string idNumber, int?jobPositionId, int?payPointId, int?serviceOfficeId, int?salaryLevelId, bool isShiftWorker, bool isCasualWorker,
                                       bool isActive, bool isDeleted, DateTime dateCreated, string createdBy)
        {
            Employee newEmployee;

            using (var dbContext = new SDIIS_DatabaseEntities())
            {
                User newUser;

                var user = new User
                {
                    User_Name    = string.Format("{0}{1}", firstName.Substring(0, 1), lastName),
                    Password     = "******",
                    First_Name   = firstName,
                    Last_Name    = lastName,
                    Is_Active    = isActive,
                    Is_Deleted   = isDeleted,
                    Date_Created = dateCreated,
                    Created_By   = createdBy
                };

                try
                {
                    newUser = dbContext.Users.Add(user);
                    dbContext.SaveChanges();
                }
                catch (Exception)
                {
                    return(null);
                }

                if (newUser == null)
                {
                    return(null);
                }

                var employee = new Employee
                {
                    User_Id               = newUser.User_Id,
                    Persal_Number         = persalNumber,
                    Head_Of_Department_Id = headOfDepartmentId,
                    Supervisor_Id         = supervisorId,
                    Phone_Number          = phoneNumber,
                    Mobile_Phone_Number   = mobilePhoneNumber,
                    Gender_Id             = genderId,
                    Race_Id               = raceId,
                    ID_Number             = idNumber,
                    Job_Position_Id       = jobPositionId,
                    Paypoint_Id           = payPointId,
                    Service_Office_Id     = serviceOfficeId,
                    Salary_Level_Id       = salaryLevelId,
                    Is_Shift_Worker       = isShiftWorker,
                    Is_Casual_Worker      = isCasualWorker,
                    Is_Active             = isActive,
                    Is_Deleted            = isDeleted,
                    Date_Created          = dateCreated,
                    Created_By            = createdBy
                };

                try
                {
                    newEmployee = dbContext.Employees.Add(employee);
                    dbContext.SaveChanges();
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            return(newEmployee);
        }
Esempio n. 8
0
        private IEnumerable <Module_Action> PopulateAdditionalItems(IEnumerable <Module_Action> listOfModuleActions, SDIIS_DatabaseEntities dbContext)
        {
            var populatedModuleActions = new List <Module_Action>();

            populatedModuleActions = (from m in listOfModuleActions
                                      select m.Set(m1 =>
            {
                m1.Module_Id = m.Module_Controller.Module_Id;
            })).ToList();

            return(populatedModuleActions);
        }