/// <summary> /// Client Read /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <param name="eventClient"> </param> public static ClientReadResponse ClientReadFull(ClientReadRequest clientReadRequest) { // Check if the user can access the client record // bool isadmin = false; string userid = clientReadRequest.headerInfo.UserID; var sur = new SecurityUserRole(); var clientReadResponse = RepClient.Read(clientReadRequest.clientUID); if (sur.UserHasAccessToRole(userid, FCMConstant.UserRoleType.ADMIN)) { // ok } else { if (sur.UserHasAccessToRole(userid, FCMConstant.UserRoleType.CLIENT)) { if (clientReadResponse.client.FKUserID.ToUpper() == clientReadRequest.headerInfo.UserID.ToUpper()) { //ok } else { return(new ClientReadResponse()); } } else { return(new ClientReadResponse()); } } clientReadResponse.client.clientExtraInformation = new ClientExtraInformation(); clientReadResponse.client.clientExtraInformation.FKClientUID = clientReadResponse.client.UID; RepClientExtraInformation.Read(clientReadResponse.client.clientExtraInformation); clientReadResponse.client.clientEmployee = RepEmployee.ReadEmployees(clientReadRequest.clientUID); return(clientReadResponse); }
/// <summary> /// Add Employee /// </summary> /// <param name="clientAddRequest"></param> /// <param name="employeeName"> </param> /// <param name="roleType"></param> private static void SaveEmployees(int clientUID, ClientEmployee inClientEmployee, string userID) { ClientEmployee clientEmployee = new ClientEmployee(); clientEmployee = RepEmployee.ReadEmployees(clientUID); // ManagingDirector if (string.IsNullOrEmpty(clientEmployee.ManagingDirector)) { AddEmployee(inClientEmployee.ManagingDirector, FCMConstant.RoleTypeCode.ManagingDirector, userID, clientUID); } else { UpdateEmployee(inClientEmployee.ManagingDirector, FCMConstant.RoleTypeCode.ManagingDirector, userID, clientUID); } // ProjectManager if (string.IsNullOrEmpty(clientEmployee.ProjectManager)) { AddEmployee(inClientEmployee.ProjectManager, FCMConstant.RoleTypeCode.ProjectManager, userID, clientUID); } else { UpdateEmployee(inClientEmployee.ProjectManager, FCMConstant.RoleTypeCode.ProjectManager, userID, clientUID); } // ProjectOHSRepresentative if (string.IsNullOrEmpty(clientEmployee.ProjectOHSRepresentative)) { AddEmployee(inClientEmployee.ProjectOHSRepresentative, FCMConstant.RoleTypeCode.ProjectOHSRepresentative, userID, clientUID); } else { UpdateEmployee(inClientEmployee.ProjectOHSRepresentative, FCMConstant.RoleTypeCode.ProjectOHSRepresentative, userID, clientUID); } // OHSEAuditor if (string.IsNullOrEmpty(clientEmployee.OHSEAuditor)) { AddEmployee(inClientEmployee.ProjectOHSRepresentative, FCMConstant.RoleTypeCode.OHSEAuditor, userID, clientUID); } else { UpdateEmployee(inClientEmployee.ProjectOHSRepresentative, FCMConstant.RoleTypeCode.OHSEAuditor, userID, clientUID); } // SystemsManager if (string.IsNullOrEmpty(clientEmployee.SystemsManager)) { AddEmployee(inClientEmployee.SystemsManager, FCMConstant.RoleTypeCode.SystemsManager, userID, clientUID); } else { UpdateEmployee(inClientEmployee.SystemsManager, FCMConstant.RoleTypeCode.SystemsManager, userID, clientUID); } // SiteManager if (string.IsNullOrEmpty(clientEmployee.SiteManager)) { AddEmployee(inClientEmployee.SiteManager, FCMConstant.RoleTypeCode.SiteManager, userID, clientUID); } else { UpdateEmployee(inClientEmployee.SiteManager, FCMConstant.RoleTypeCode.SiteManager, userID, clientUID); } // Supervisor if (string.IsNullOrEmpty(clientEmployee.Supervisor)) { AddEmployee(inClientEmployee.Supervisor, FCMConstant.RoleTypeCode.Supervisor, userID, clientUID); } else { UpdateEmployee(inClientEmployee.Supervisor, FCMConstant.RoleTypeCode.Supervisor, userID, clientUID); } // LeadingHand1 if (string.IsNullOrEmpty(clientEmployee.LeadingHand1)) { AddEmployee(inClientEmployee.LeadingHand1, FCMConstant.RoleTypeCode.LeadingHand1, userID, clientUID); } else { UpdateEmployee(inClientEmployee.LeadingHand1, FCMConstant.RoleTypeCode.LeadingHand1, userID, clientUID); } // LeadingHand2 if (string.IsNullOrEmpty(clientEmployee.LeadingHand2)) { AddEmployee(inClientEmployee.LeadingHand1, FCMConstant.RoleTypeCode.LeadingHand2, userID, clientUID); } else { UpdateEmployee(inClientEmployee.LeadingHand1, FCMConstant.RoleTypeCode.LeadingHand2, userID, clientUID); } // LeadingHand2 if (string.IsNullOrEmpty(clientEmployee.HealthAndSafetyRep)) { AddEmployee(inClientEmployee.LeadingHand1, FCMConstant.RoleTypeCode.HealthAndSafetyRep, userID, clientUID); } else { UpdateEmployee(inClientEmployee.LeadingHand1, FCMConstant.RoleTypeCode.HealthAndSafetyRep, userID, clientUID); } // AdministrationPerson if (string.IsNullOrEmpty(clientEmployee.HealthAndSafetyRep)) { AddEmployee(inClientEmployee.AdministrationPerson, FCMConstant.RoleTypeCode.AdministrationPerson, userID, clientUID); } else { UpdateEmployee(inClientEmployee.AdministrationPerson, FCMConstant.RoleTypeCode.AdministrationPerson, userID, clientUID); } // WorkersCompensationCoordinator if (string.IsNullOrEmpty(clientEmployee.HealthAndSafetyRep)) { AddEmployee(inClientEmployee.WorkersCompensationCoordinator, FCMConstant.RoleTypeCode.WorkersCompensationCoordinator, userID, clientUID); } else { UpdateEmployee(inClientEmployee.WorkersCompensationCoordinator, FCMConstant.RoleTypeCode.WorkersCompensationCoordinator, userID, clientUID); } }