Пример #1
0
        public override async Task <ExtPostContainer <string> > SaveInput(UserApplicatorInput input)
        {
            await Validate(input);

            var id   = !string.IsNullOrWhiteSpace(input.Id) ? input.Id : Guid.NewGuid().ToString("N");
            var user = new UserApplicator {
                Id          = id,
                Name        = input.Name,
                Rut         = input.Rut,
                Email       = input.Email,
                IdsRoles    = input.IdsRoles,
                IdJob       = input.IdJob,
                IdNebulizer = input.IdNebulizer,
                IdTractor   = input.IdTractor
            };

            if (string.IsNullOrWhiteSpace(input.Id))
            {
                user.ObjectIdAAD = await graphApi.CreateUserIntoActiveDirectory(input.Name, input.Email);
            }
            else
            {
                user.ObjectIdAAD = (await Get(id)).Result.ObjectIdAAD;
            }
            await SaveDb(user);

            return(await SaveSearch(user));
        }
Пример #2
0
        public async Task <ExtPostContainer <string> > SaveInput(UserApplicatorInput input, bool isBatch)
        {
            await Validate(input);

            var id   = !string.IsNullOrWhiteSpace(input.Id) ? input.Id : Guid.NewGuid().ToString("N");
            var user = new UserApplicator {
                Id          = id,
                Name        = input.Name,
                Rut         = input.Rut,
                Email       = input.Email,
                IdsRoles    = input.IdsRoles,
                IdJob       = input.IdJob,
                IdNebulizer = input.IdNebulizer,
                IdTractor   = input.IdTractor
            };

            if (string.IsNullOrWhiteSpace(input.Id))
            {
                user.ObjectIdAAD = await graphApi.CreateUserIntoActiveDirectory(input.Name, input.Email);
            }
            else
            {
                user.ObjectIdAAD = (await Get(id)).Result.ObjectIdAAD;
            }
            if (!isBatch)
            {
                return(await Save(user));
            }
            await repo.CreateEntityContainer(user);

            return(new ExtPostContainer <string> {
                IdRelated = id,
                MessageResult = ExtMessageResult.Ok
            });
        }