예제 #1
0
        public IActionResult Create([FromBody] TempEmployee toCreate)
        {
            if (toCreate == null)
            {
                var newEmployeeUtils = new EmployeeUtils();

                return(Json(newEmployeeUtils.GetAllEmployees()));
            }
            else
            {
                var newEmployeeUtils = new EmployeeUtils();
                try
                {
                    if (toCreate.RawPw == null)
                    {
                        return(BadRequest("Your Password is Missing!!!!"));
                    }

                    var newEmpId = newEmployeeUtils.CreateNewUser(toCreate);
                    if (newEmpId > 0)
                    {
                        return(Json(newEmpId));
                    }
                    return(BadRequest("Couldnt create the Employee!"));
                }
                catch (Exception e)
                {
                    return(BadRequest("Couldnt create the Employee!" + e));
                }
            }
        }
예제 #2
0
        public IActionResult UpdateInfo([FromBody] EmployeeInfoToShare updatedInfo, int id)
        {
            if (updatedInfo != null)
            {
                var newEmployeeUtils = new EmployeeUtils();
                if (updatedInfo.FirstName != null)
                {
                    updatedInfo.EmployeeId = id;
                    if (newEmployeeUtils.EditEmployeeAccount(updatedInfo))
                    {
                        return(NoContent());
                    }
                }
                return(BadRequest("Invalid Input!!!"));
            }
            else
            {
                var newEmployeeUtils = new EmployeeUtils();
                var empToClean       = newEmployeeUtils.GetEmployeeById(id);
                if (empToClean != null)
                {
                    return(Ok(empToClean));
                }

                return(NotFound($"Couldnt find an Employee with the ID: {id}"));
            }
        }
        public IActionResult Create([FromBody] Login credentials)
        {
            if (credentials.Username.ToString() == null || credentials.Password == null)
            {
                return(BadRequest("Username or Password was not provided!"));
            }

            var newEmpUtil = new EmployeeUtils();

            try
            {
                var newEmployee = newEmpUtil.LogIn(credentials.Username, credentials.Password);

                if (newEmployee != null)
                {
                    if (!checkforSession(credentials.Username))
                    {
                        _context.Employees.Add(newEmployee);
                        _context.SaveChanges();
                        return(CreatedAtRoute("LoginEmployee", new { id = newEmployee.EmployeeId }, newEmployee));
                    }
                    return(Json(newEmployee));
                }
                return(NotFound($"Couldn't Login Employee {credentials.Username}! "));
            }
            catch (Exception e)
            {
                return(NotFound($"Couldn't Login Employee {credentials.Username}! " + e));
            }
        }
        protected static FR_L5EM_GEAAWCFTAE_1403 Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_GEAAWCFTAE_1403 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5EM_GEAAWCFTAE_1403();
            returnValue.Result = new L5EM_GEAAWCFTAE_1403();
            //Put your code here

            L5EM_GEAAWCFT_1210[] employees = cls_Get_Employees_And_ActiveWorkingContracts_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            if (employees == null)
            {
                employees = new L5EM_GEAAWCFT_1210[0];
                returnValue.Result.Employees = employees;
                return(returnValue);
            }
            L5EM_GEAAWCFT_1210 loggedEmployee = employees.Where(i => i.CMN_BPT_EMP_EmployeeID == Parameter.EmployeeID).FirstOrDefault();
            L5CM_GCSFT_1157    company        = cls_Get_Company_Structure_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;


            EmployeeUtils employeeUtils = new EmployeeUtils();
            employeeUtils.ComapnyStructure = company;
            List <Guid> employeesUnderManager = employeeUtils.getEmployeesForManager(Parameter.appStartDate, employees, company, Parameter.EmployeeID, securityTicket.SessionTicket);
            if (loggedEmployee == null)
            {
                employees = employees.Where(i => employeesUnderManager.Contains(i.CMN_BPT_EMP_EmployeeID)).ToArray();
            }


            employees = employees.Where(i => employeesUnderManager.Contains(i.CMN_BPT_EMP_EmployeeID) || EmployeeUtils.getEmployeeWorkplaceHistoriesFromAppStartDate(i.EmployeeWorkplaceHistory, Parameter.appStartDate).Intersect(EmployeeUtils.getEmployeeWorkplaceHistoriesFromAppStartDate(loggedEmployee.EmployeeWorkplaceHistory, Parameter.appStartDate)).Any()).ToArray();
            if (employees.Where(i => i.CMN_BPT_EMP_EmployeeID == Parameter.EmployeeID).ToArray().Length == 0)
            {
                if (loggedEmployee != null)
                {
                    if (employees.Length == 0)
                    {
                        employees    = new L5EM_GEAAWCFT_1210[1];
                        employees[0] = loggedEmployee;
                    }
                    else
                    {
                        L5EM_GEAAWCFT_1210[] employeeList = new L5EM_GEAAWCFT_1210[employees.Length + 1];
                        for (int i = 0; i < employees.Length; i++)
                        {
                            employeeList[i] = employees[i];
                        }
                        employeeList[employees.Length] = loggedEmployee;
                        employees = employeeList;
                    }
                }
            }
            returnValue.Result.Employees = employees;

            if (employees.Length == 0)
            {
                returnValue.Result = null;
            }
            return(returnValue);

            #endregion UserCode
        }
예제 #5
0
 //DELETE : Employee
 public ActionResult DeleteEmployee(int Id)
 {
     if (EmployeeUtils.DeleteEmployee(Id))
     {
         return(RedirectToAction("ListEmployees"));
     }
     return(RedirectToAction("ListEmployees"));
 }
        public static IEnumerable <EmployeeDTO> SearchEmployeesDTOs(List <ParamEmployeeId> paramEmployeeIds)
        {
            var listEmployee = LoadEmployees();
            var listDTO      = from emp in listEmployee
                               where EmployeeUtils.BelongsToIds(emp, paramEmployeeIds)
                               select ContractFactory.BuildContract(emp).GenerateDTO();

            return(listDTO);
        }
예제 #7
0
        protected static FR_L5ST_GSTFSPI_1037 Execute(DbConnection Connection, DbTransaction Transaction, P_L5ST_GSTFSPI_1037 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5ST_GSTFSPI_1037();
            returnValue.Result = new L5ST_GSTFSPI_1037();

            L5CM_GCSFT_1157      company              = cls_Get_Company_Structure_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            L6TN_GSFT_1017       settingsForTenant    = cls_Get_Settings_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            StructureBuilderUtil structureBuilderUtil = new StructureBuilderUtil();
            TreeNodeUtil         treeNodeUtil         = new TreeNodeUtil();
            List <Guid>          structurePartsList   = new List <Guid>();
            structurePartsList.Add(Parameter.StructurePartID);

            structureBuilderUtil.company         = cls_Get_Company_Structure_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;;
            structureBuilderUtil.sessionToken    = securityTicket.SessionTicket;
            structureBuilderUtil.addEmployees    = false;
            structureBuilderUtil.employees       = cls_Get_Employees_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            structureBuilderUtil.sessionSettings = cls_Get_Settings_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            structureBuilderUtil.startDate       = cls_Get_CalculationTimeFramesForTenant.Invoke(Connection, Transaction, securityTicket).Result.Min(x => x.CalculationTimeframe_StartDate).Date;
            structureBuilderUtil.endDate         = DateTime.Now;
            structureBuilderUtil.hidenNodeType   = CompanyStructureType.None;

            EmployeeUtils employeeUtil = new EmployeeUtils();
            structureBuilderUtil.employeeUtil = employeeUtil;

            List <Node>            companyStructure        = structureBuilderUtil.organizeData(DateTime.Now);
            List <L5ST_GSTFT_1610> remainingShiftTemplates = new List <L5ST_GSTFT_1610>();
            List <L5ST_GSTFT_1610> tempShiftTemplates      = new List <L5ST_GSTFT_1610>();

            Node foundNode = treeNodeUtil.findNodeForID(companyStructure[0], Parameter.StructurePartID);
            if (foundNode != null)
            {
                treeNodeUtil.getParentIDsForStructurePart(foundNode, structurePartsList);

                L5ST_GSTFT_1610[] shiftTemplates = cls_Get_ShiftTemplates_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;

                foreach (var structureID in structurePartsList)
                {
                    tempShiftTemplates = shiftTemplates.Where(i => (i.CMN_STR_Office_RefID == structureID && structureID != Guid.Empty) || (i.CMN_STR_Workarea_RefID == structureID && structureID != Guid.Empty) || (i.CMN_STR_Workplace_RefID == structureID && structureID != Guid.Empty) || (i.CMN_STR_Workplace_RefID == Guid.Empty && i.CMN_STR_Workarea_RefID == Guid.Empty && i.CMN_STR_Office_RefID == Guid.Empty)).ToList();
                    foreach (var shiftTemplate in tempShiftTemplates)
                    {
                        if (!remainingShiftTemplates.Contains(shiftTemplate))
                        {
                            remainingShiftTemplates.Add(shiftTemplate);
                        }
                    }
                }
            }
            returnValue.Result.ShiftTemplates = remainingShiftTemplates.ToArray();

            //Put your code here
            return(returnValue);

            #endregion UserCode
        }
예제 #8
0
 public ActionResult CreateEmployee(Employee employee)
 {
     if (ModelState.IsValid)
     {
         if (EmployeeUtils.InsertEmployee(Mappings.MappingDtos.ModelEmployeeToEntityEmployee(employee)))
         {
             return(RedirectToAction("ListEmployees"));
         }
     }
     return(View(employee));
 }
예제 #9
0
        public IActionResult Create([FromBody] Logout credentials)
        {
            var newEmpUtil = new EmployeeUtils();
            var toLogOut   = newEmpUtil.ViewEmployeeAccount(credentials.Username);

            if (toLogOut == null)
            {
                return(NotFound("Employee was Not Found!"));
            }
            return(new NoContentResult());
        }
예제 #10
0
        //GET: Employees
        public ActionResult ListEmployees(int?page, string searchString)
        {
            List <DataAccessLayer.Entities.Employee> empContextList = EmployeeUtils.GetAllEmplyees();
            List <Employee> empList = Mappings.MappingDtos.EntityEmployeeToModelEmployeeAsList(empContextList);

            if (!String.IsNullOrEmpty(searchString))
            {
                empList = empList.Where(s => s.Name.ToLower().Contains(searchString.ToLower())).ToList();
            }
            return(View(empList.ToPagedList(page ?? 1, pageSize: 20)));
        }
예제 #11
0
 public ActionResult EditEmployee(int Id, Employee Employee)
 {
     if (ModelState.IsValid)
     {
         if (EmployeeUtils.UpdateEmployee(Mappings.MappingDtos.ModelEmployeeToEntityEmployee(Employee)))
         {
             return(RedirectToAction("ListEmployees"));
         }
         return(View(Employee));
     }
     return(View(Employee));
 }
예제 #12
0
        public IActionResult GetEmployeeInfoById(int id)
        {
            var newEmployeeUtils = new EmployeeUtils();
            var empToClean       = newEmployeeUtils.GetEmployeeById(id);

            if (empToClean != null)
            {
                return(Ok(empToClean));
            }

            return(NotFound($"Couldnt find an Employee with the ID: {id}"));
        }
예제 #13
0
 public ActionResult Login(Employee user)
 {
     if (EmployeeUtils.AuthenticationEmployee(user.Name, user.Password))
     {
         Session["LoginedUser"] = user.Name;
         if (user.Name == "Admin")
         {
             return(RedirectToAction("Index", "Admin"));
         }
         return(RedirectToAction("Index", "Employee"));
     }
     return(RedirectToAction("LoginError"));
 }
예제 #14
0
        public static DataAccessLayer.Entities.Event ModelEventToEntityEvent(Models.Event modelEvent)
        {
            DataAccessLayer.Entities.Event entityEvent = new DataAccessLayer.Entities.Event()
            {
                Card     = ClientUtils.GetClientByTicketId(modelEvent.TicketId),
                Date     = modelEvent.Date,
                Id       = modelEvent.Id,
                Inserter = EmployeeUtils.GetEmployeeByName(modelEvent.EmployeeName),
                Room     = RoomUtils.GetRoomByName(modelEvent.RoomName),
                Ticket   = TicketUtils.GetTicketById(modelEvent.TicketId),
                Type     = modelEvent.Type
            };

            return(entityEvent);
        }
예제 #15
0
 public IActionResult UpdateInfo([FromBody] EmployeeInfoToShare updatedInfo, int id)
 {
     if (updatedInfo != null)
     {
         var newEmployeeUtils = new EmployeeUtils();
         if (updatedInfo.FirstName != null)
         {
             updatedInfo.EmployeeId = id;
             if (newEmployeeUtils.EditEmployeeAccount(updatedInfo))
             {
                 return(NoContent());
             }
         }
     }
     return(BadRequest("Invalid Input!!!"));
 }
        public IActionResult Create([FromBody] TempEmployee toCreate)
        {
            var newEmployeeUtils = new EmployeeUtils();

            try
            {
                if (toCreate.RawPw == null)
                {
                    return(BadRequest("Your Password is Missing!!!!"));
                }


                if (newEmployeeUtils.CreateNewUser(toCreate))
                {
                    return(NoContent());
                }
                return(BadRequest("Couldnt create the Employee!"));
            }
            catch (Exception e)
            {
                return(BadRequest("Couldnt create the Employee!" + e));
            }
        }
        public IActionResult ResetPw([FromBody] PWResetInfo newCustInfo, int id)
        {
            if (newCustInfo.ManagerInfo.Username.ToString() == null || newCustInfo.ManagerInfo.Password == null)
            {
                return(BadRequest("Username or Password was not provided!"));
            }

            var newEmpUtil = new EmployeeUtils();

            try
            {
                var newEmployee = newEmpUtil.LogIn(newCustInfo.ManagerInfo.Username, newCustInfo.ManagerInfo.Password);

                if (newEmployee != null)
                {
                    var newEmployeeUtils = new EmployeeUtils();
                    var empToClean       = newEmployeeUtils.GetEmployeeById(id);
                    if (empToClean != null)
                    {
                        Login updatedInfo = new Login();
                        updatedInfo.Username = id;
                        updatedInfo.Password = newCustInfo.NewPw;

                        if (newEmployeeUtils.EditEmployeePW(updatedInfo))
                        {
                            return(Ok());
                        }
                        return(StatusCode(500, "Error, Couldnt update the User Password! "));
                    }
                }
                return(NotFound($"Couldn't Login Employee {newCustInfo.ManagerInfo.Username}! "));
            }
            catch (Exception e)
            {
                return(NotFound($"You Broke something, Great Job!! " + e));
            }
        }
예제 #18
0
        public IActionResult Create([FromBody] Login credentials, int id)
        {
            if (credentials.Username.ToString() == null || credentials.Password == null)
            {
                return(BadRequest("Username or Password was not provided!"));
            }

            var newEmpUtil = new EmployeeUtils();

            try
            {
                var newEmployee = newEmpUtil.LogIn(credentials.Username, credentials.Password);

                if (newEmployee != null)
                {
                    return(Json(newEmployee));
                }
                return(NotFound($"Couldn't Login Employee {credentials.Username}! "));
            }
            catch (Exception e)
            {
                return(NotFound($"Couldn't Login Employee {credentials.Username}! " + e));
            }
        }
 protected override QueryFilters <EmployeeProperty> GetChanges(Employee original, Employee changed)
 {
     return(EmployeeUtils.GetChanges(original, changed));
 }
        public IEnumerable <EmployeeInfoToShare> GetAll()
        {
            var newEmployeeUtils = new EmployeeUtils();

            return(newEmployeeUtils.GetAllEmployees());
        }
예제 #21
0
        public ActionResult SaveToXls(string what)
        {
            DataTable dt     = null;
            bool      result = false;

            switch (what)
            {
            case "Client":
                List <DataAccessLayer.Entities.Client> layerClientList = ClientUtils.GetAllClients();
                List <Client> clientList = Mappings.MappingDtos.EntityClientToModelClientAsList(layerClientList);
                dt     = DataToExcel.ConvertToDataTable(clientList);
                result = DataToExcel.FlushToExcel <Client>(dt);
                break;

            case "Employee":
                List <DataAccessLayer.Entities.Employee> layerEmplyeeList = EmployeeUtils.GetAllEmplyees();
                List <Employee> employeeList = Mappings.MappingDtos.EntityEmployeeToModelEmployeeAsList(layerEmplyeeList);
                dt     = DataToExcel.ConvertToDataTable(employeeList);
                result = DataToExcel.FlushToExcel <Employee>(dt);
                break;

            case "Event":
                List <DataAccessLayer.Entities.Event> layerEventList = EventUtils.GetAllEvents();
                List <Event> eventList = Mappings.MappingDtos.EntityEventToModelEventList(layerEventList);
                dt     = DataToExcel.ConvertToDataTable(eventList);
                result = DataToExcel.FlushToExcel <Event>(dt);
                break;

            case "Room":
                List <DataAccessLayer.Entities.Room> layerRoomList = RoomUtils.GetAllRooms();
                List <Room> roomList = Mappings.MappingDtos.EntityRoomToModelRoomAsList(layerRoomList);
                dt     = DataToExcel.ConvertToDataTable(roomList);
                result = DataToExcel.FlushToExcel <Room>(dt);
                break;

            case "Ticket":
                List <DataAccessLayer.Entities.Ticket> layerTicketList = TicketUtils.GetAllTickets();
                List <Ticket> ticketList = Mappings.MappingDtos.EntityTicketLIstToModelTicketAsList(layerTicketList);
                dt     = DataToExcel.ConvertToDataTable(ticketList);
                result = DataToExcel.FlushToExcel <Ticket>(dt);
                break;

            case "Type":
                List <DataAccessLayer.Entities.TicketType> layerTypeList = TicketTypeUtils.GetAllTicketTypes();
                List <TicketType> typeList = Mappings.MappingDtos.EntityTicketLIstToModelTicketTypeAsList(layerTypeList);
                dt     = DataToExcel.ConvertToDataTable(typeList);
                result = DataToExcel.FlushToExcel <TicketType>(dt);
                break;

            default:
                break;
            }

            if (result)
            {
                return(RedirectToAction("ListEmployees"));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
 protected override void Merge(Employee source, Employee target)
 {
     EmployeeUtils.Merge(source, target);
 }
        protected static FR_L5CM_CSNU_1524 Execute(DbConnection Connection, DbTransaction Transaction, P_L5CM_CSNU_1524 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5CM_CSNU_1524();

            StructureBuilderUtil structureBuilderUtil = new StructureBuilderUtil();
            TreeNodeUtil         treeNodeUtil         = new TreeNodeUtil();

            structureBuilderUtil.company         = cls_Get_Company_Structure_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;;
            structureBuilderUtil.sessionToken    = securityTicket.SessionTicket;
            structureBuilderUtil.addEmployees    = false;
            structureBuilderUtil.sessionSettings = cls_Get_Settings_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            structureBuilderUtil.startDate       = cls_Get_CalculationTimeFramesForTenant.Invoke(Connection, Transaction, securityTicket).Result.Min(x => x.CalculationTimeframe_StartDate).Date;
            structureBuilderUtil.endDate         = DateTime.Now;
            structureBuilderUtil.hidenNodeType   = CompanyStructureType.None;
            structureBuilderUtil.employees       = new L5EM_GEFT_0959[0];

            EmployeeUtils employeeUtil = new EmployeeUtils();
            structureBuilderUtil.employeeUtil = employeeUtil;
            returnValue.Result = new L5CM_CSNU_1524();
            List <Node> companyStructure = structureBuilderUtil.organizeData(DateTime.Now);

            Node node = treeNodeUtil.findNodeForID(companyStructure[0], Parameter.ParentRefID);
            if (node != null && node.Children.Count != 0)
            {
                if (node.Children[0].data is L5OF_GOFT_1157)
                {
                    var officeQuery = new ORM_CMN_STR_Office.Query();
                    officeQuery.Tenant_RefID     = securityTicket.TenantID;
                    officeQuery.IsDeleted        = false;
                    officeQuery.Office_ShortName = Parameter.ShortName;
                    var officeQueryRes = ORM_CMN_STR_Office.Query.Search(Connection, Transaction, officeQuery);

                    if (officeQueryRes.Count > 0)
                    {
                        if (officeQueryRes.Count > 0)
                        {
                            returnValue.Result.OfficeID        = officeQueryRes[0].CMN_STR_OfficeID;
                            returnValue.Result.OfficeShortName = officeQueryRes[0].Office_ShortName;
                        }
                    }
                }
                else if (node.Children[0].data is L5WA_GWAFT_1201)
                {
                    var workareaQuery = new ORM_CMN_STR_PPS_WorkArea.Query();
                    workareaQuery.Tenant_RefID = securityTicket.TenantID;
                    workareaQuery.IsDeleted    = false;
                    workareaQuery.ShortName    = Parameter.ShortName;
                    if (node.data is L5WA_GWAFT_1201)
                    {
                        workareaQuery.Parent_RefID = Parameter.ParentRefID;
                    }
                    else
                    {
                        workareaQuery.Office_RefID = Parameter.ParentRefID;
                    }

                    var workareaQueryRes = ORM_CMN_STR_PPS_WorkArea.Query.Search(Connection, Transaction, workareaQuery);
                    if (workareaQueryRes.Count > 0)
                    {
                        returnValue.Result.WorkAreaID        = workareaQueryRes[0].CMN_STR_PPS_WorkAreaID;
                        returnValue.Result.WorkAreaShortName = workareaQueryRes[0].ShortName;
                    }
                }
                else if (node.Children[0].data is L5WP_GWFT_1203)
                {
                    var workplaceQuery = new ORM_CMN_STR_PPS_Workplace.Query();
                    workplaceQuery.Tenant_RefID   = securityTicket.TenantID;
                    workplaceQuery.IsDeleted      = false;
                    workplaceQuery.ShortName      = Parameter.ShortName;
                    workplaceQuery.WorkArea_RefID = Parameter.ParentRefID;
                    var workplaceQueryRes = ORM_CMN_STR_PPS_Workplace.Query.Search(Connection, Transaction, workplaceQuery);
                    if (workplaceQueryRes.Count > 0)
                    {
                        if (workplaceQueryRes.Count > 0)
                        {
                            returnValue.Result.WorkPlaceID        = workplaceQueryRes[0].CMN_STR_PPS_WorkplaceID;
                            returnValue.Result.WorkPlaceShortName = workplaceQueryRes[0].ShortName;
                        }
                    }
                }
            }


            return(returnValue);

            #endregion UserCode
        }