Exemplo n.º 1
0
        /// <summary>
        /// Yeni Personel Ekler.
        /// </summary>
        public async Task AddPersonAsync(PersonAddDto personAddDto)
        {
            var newPerson = new Person
            {
                TCNumber    = personAddDto.TCNumber,
                Name        = personAddDto.Name,
                Surname     = personAddDto.Surname,
                PhoneNumber = personAddDto.PhoneNumber,
                Mail        = personAddDto.Mail,
            };

            _dbContext.Persons.Add(newPerson);
            await _dbContext.SaveChangesAsync();


            var currentUser = await _dbContext.Persons.Where(p => !p.IsDeleted && p.TCNumber == personAddDto.TCNumber)
                              .SingleOrDefaultAsync();

            var newAppUser = new UserRegisterDto
            {
                TCNumber  = currentUser.TCNumber,
                FirstName = currentUser.Name,
                LastName  = currentUser.Surname,
                Email     = currentUser.Mail,
                Password  = random.Next(99999, 1000000).ToString()
            };

            _authService.Register(newAppUser);
        }
 public static Person ToEntity(this PersonAddDto dto)
 {
     return(new Person()
     {
         Id = Guid.NewGuid(),
         LastName = dto.LastName,
         FirstName = dto.FirstName,
         VatNumber = dto.VatNumber,
         EmploymentStatusId = dto.EmploymentStatusId,
         Address = dto.Address.ToEntity()
     });
 }
Exemplo n.º 3
0
        public PersonGetDto AddPerson(PersonAddDto p)
        {
            //Get employment status
            EmploymentStatus status = _personRepo.GetEmploymentStatus(p.EmploymentStatusId);

            if (status.StatusName.Equals("Indépendant") && string.IsNullOrWhiteSpace(p.VatNumber))
            {
                throw new VatNumberRequiredException();
            }

            return(_personRepo
                   .AddPerson(p.ToEntity())
                   .ToDto());
        }
Exemplo n.º 4
0
        public async Task <ActionResult <string> > AddPersonAsync(PersonAddDto personAddDto)
        {
            //var validator = new PersonAddValidator(_personservice);
            //var validatorResults = validator.Validate(personAddDto);

            //if (!validatorResults.IsValid)
            //{
            //    return BadRequest(validatorResults);
            //}

            try
            {
                await _personservice.AddPersonAsync(personAddDto);

                return(StatusCode(StatusCodes.Status201Created));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
 public ActionResult <PersonGetDto> AddPerson(PersonAddDto dto)
 {
     return(Ok(_personManager.AddPerson(dto)));
 }
Exemplo n.º 6
0
 public async Task AddPerson(PersonAddDto dto)
 => await Task.Delay(1);