コード例 #1
0
        public static Result <User> CreateUserFromFile(ObjectId id, string name, string username, string email, string lineManager, string lineManagerEmail, DateTimeOffset serviceDate,
                                                       string education, string gender, bool?manager, long?cge, long?idCr, string coHead, RelationalItem company, RelationalItem businessGroup, RelationalItem businessUnit,
                                                       RelationalItem country, string language, RelationalItem frontBackOffice, RelationalItem Job, RelationalItem location, RelationalItem rank, List <RelationalItem> sectors,
                                                       RelationalItem segment)
        {
            User newObj = new Student(username, name, email, username.ToUpper(), false)
            {
                Id               = id,
                LineManager      = lineManager,
                LineManagerEmail = lineManagerEmail,
                ServiceDate      = serviceDate,
                Education        = education,
                Gender           = gender,
                Manager          = manager,
                Cge              = cge,
                IdCr             = idCr,
                CoHead           = coHead,
                Company          = company,
                BusinessGroup    = businessGroup,
                BusinessUnit     = businessUnit,
                Country          = country,
                Language         = language,
                FrontBackOffice  = frontBackOffice,
                Job              = Job,
                Location         = location,
                Rank             = rank,
                Sectors          = sectors,
                Segment          = segment,
                FirstAccess      = true,
                EmailVerified    = true
            };

            return(Result.Ok(newObj));
        }
コード例 #2
0
        public static Result <User> CreateUser(string name, string email, string userName, string registrationId, string cpf,
                                               string responsible, string lineManager, string info, string phone, string imageUrl, string role, RelationalItem businessGroup = null,
                                               RelationalItem businessUnit = null, RelationalItem country = null, RelationalItem frontBack      = null, RelationalItem job     = null,
                                               RelationalItem location     = null, RelationalItem rank    = null, List <RelationalItem> sectors = null, RelationalItem segment = null)
        {
            User newObj = null;

            switch (role)
            {
            case "Student":
                newObj = new Student(userName, name, email, userName.ToUpper(), false)
                {
                    RegistrationId  = registrationId,
                    Cpf             = cpf,
                    ResponsibleId   = string.IsNullOrEmpty(responsible) ? ObjectId.Empty : ObjectId.Parse(responsible),
                    LineManager     = lineManager,
                    Info            = info,
                    Phone           = phone,
                    ImageUrl        = imageUrl,
                    Country         = country,
                    Location        = location,
                    BusinessGroup   = businessGroup,
                    BusinessUnit    = businessUnit,
                    FrontBackOffice = frontBack,
                    Job             = job,
                    Rank            = rank,
                    Sectors         = sectors,
                    Segment         = segment,
                    FirstAccess     = true,
                    EmailVerified   = true
                };
                break;

            case "Admin":
                newObj = new Admin(userName, name, email, userName.ToUpper(), false)
                {
                    RegistrationId  = registrationId,
                    Cpf             = cpf,
                    ResponsibleId   = string.IsNullOrEmpty(responsible) ? ObjectId.Empty : ObjectId.Parse(responsible),
                    LineManager     = lineManager,
                    Info            = info,
                    Phone           = phone,
                    ImageUrl        = imageUrl,
                    Country         = country,
                    Location        = location,
                    BusinessGroup   = businessGroup,
                    BusinessUnit    = businessUnit,
                    FrontBackOffice = frontBack,
                    Job             = job,
                    Rank            = rank,
                    Sectors         = sectors,
                    Segment         = segment,
                    FirstAccess     = false,
                    EmailVerified   = true
                };
                break;

            case "HumanResources":
                newObj = new HumanResources(userName, name, email, userName.ToUpper(), false)
                {
                    RegistrationId  = registrationId,
                    Cpf             = cpf,
                    ResponsibleId   = string.IsNullOrEmpty(responsible) ? ObjectId.Empty : ObjectId.Parse(responsible),
                    LineManager     = lineManager,
                    Info            = info,
                    Phone           = phone,
                    ImageUrl        = imageUrl,
                    Country         = country,
                    Location        = location,
                    BusinessGroup   = businessGroup,
                    BusinessUnit    = businessUnit,
                    FrontBackOffice = frontBack,
                    Job             = job,
                    Rank            = rank,
                    Sectors         = sectors,
                    Segment         = segment,
                    FirstAccess     = false,
                    EmailVerified   = true
                };
                break;

            case "Secretary":
                newObj = new Secretary(userName, name, email, userName.ToUpper(), false)
                {
                    RegistrationId  = registrationId,
                    Cpf             = cpf,
                    ResponsibleId   = string.IsNullOrEmpty(responsible) ? ObjectId.Empty : ObjectId.Parse(responsible),
                    LineManager     = lineManager,
                    Info            = info,
                    Phone           = phone,
                    ImageUrl        = imageUrl,
                    Country         = country,
                    Location        = location,
                    BusinessGroup   = businessGroup,
                    BusinessUnit    = businessUnit,
                    FrontBackOffice = frontBack,
                    Job             = job,
                    Rank            = rank,
                    Sectors         = sectors,
                    Segment         = segment,
                    FirstAccess     = false,
                    EmailVerified   = true
                };
                break;

            case "Recruiter":
                newObj = new Recruiter(userName, name, email, userName.ToUpper(), false)
                {
                    RegistrationId  = registrationId,
                    Cpf             = cpf,
                    ResponsibleId   = string.IsNullOrEmpty(responsible) ? ObjectId.Empty : ObjectId.Parse(responsible),
                    LineManager     = lineManager,
                    Info            = info,
                    Phone           = phone,
                    ImageUrl        = imageUrl,
                    Country         = country,
                    Location        = location,
                    BusinessGroup   = businessGroup,
                    BusinessUnit    = businessUnit,
                    FrontBackOffice = frontBack,
                    Job             = job,
                    Rank            = rank,
                    Sectors         = sectors,
                    Segment         = segment,
                    FirstAccess     = true,
                    EmailVerified   = true
                };
                break;

            case "BusinessManager":
                newObj = new BusinessManager(userName, name, email, userName.ToUpper(), false)
                {
                    RegistrationId  = registrationId,
                    Cpf             = cpf,
                    ResponsibleId   = string.IsNullOrEmpty(responsible) ? ObjectId.Empty : ObjectId.Parse(responsible),
                    LineManager     = lineManager,
                    Info            = info,
                    Phone           = phone,
                    ImageUrl        = imageUrl,
                    Country         = country,
                    Location        = location,
                    BusinessGroup   = businessGroup,
                    BusinessUnit    = businessUnit,
                    FrontBackOffice = frontBack,
                    Job             = job,
                    Rank            = rank,
                    Sectors         = sectors,
                    Segment         = segment,
                    FirstAccess     = true,
                    EmailVerified   = true
                };
                break;

            case "Author":
                newObj = new Author(userName, name, email, userName.ToUpper(), false)
                {
                    RegistrationId  = registrationId,
                    Cpf             = cpf,
                    ResponsibleId   = string.IsNullOrEmpty(responsible) ? ObjectId.Empty : ObjectId.Parse(responsible),
                    LineManager     = lineManager,
                    Info            = info,
                    Phone           = phone,
                    ImageUrl        = imageUrl,
                    Country         = country,
                    Location        = location,
                    BusinessGroup   = businessGroup,
                    BusinessUnit    = businessUnit,
                    FrontBackOffice = frontBack,
                    Job             = job,
                    Rank            = rank,
                    Sectors         = sectors,
                    Segment         = segment,
                    FirstAccess     = true,
                    EmailVerified   = true
                };
                break;

            default:
                return(Result.Fail <User>("Role nao existe"));
            }

            return(Result.Ok(newObj));
        }