public async Task <PersonalDto> Create(PersonalCreateDto model)
        {
            var entry = new Personal
            {
                Nombres          = model.Nombres,
                Apellido_Paterno = model.Apellido_Paterno,
                Apellido_Materno = model.Apellido_Materno,
                Email            = model.Email,
                Direccion        = model.Direccion,
                Dni                    = model.Dni,
                EsCoordinador          = model.EsCoordinador,
                Experiencia_Especifica = model.Experiencia_Especifica,
                Experiencia_General    = model.Experiencia_General,
                Perfil                 = model.Perfil,
                CCI                    = model.CCI,
                Nro_Celular            = model.Nro_Celular,
                Ruc                    = model.Ruc
            };

            await _context.AddAsync(entry);

            await _context.SaveChangesAsync();

            return(_mapper.Map <PersonalDto>(entry));
        }
Esempio n. 2
0
        public PersonalReadDto Update(int id, PersonalCreateDto dto)
        {
            var personal = _context.Personal.FirstOrDefault(e => e.Id == id);

            if (personal == null)
            {
                throw new BusinessException("Admin does not exist");
            }

            personal.CreatedAt  = dto.CreatedAt;
            personal.Balance    = dto.Balance;
            personal.Username   = dto.Username;
            personal.Name       = dto.Name;
            personal.Surname    = dto.Surname;
            personal.Email      = dto.Email;
            personal.Address    = dto.Address;
            personal.City       = dto.City;
            personal.Mobile     = dto.Mobile;
            personal.Password   = dto.Password;
            personal.IsPersonal = dto.IsPersonal;

            _context.SaveChanges();

            return(_mapper.Map <PersonalReadDto>(personal));
        }
Esempio n. 3
0
        public async Task <ActionResult> Create(PersonalCreateDto model)
        {
            var result = await _personalService.Create(model);

            return(CreatedAtAction(
                       "GetById",
                       new { id = result.PersonalId },
                       result));
        }
Esempio n. 4
0
        public PersonalReadDto Create(PersonalCreateDto dto)
        {
            var personal = _mapper.Map <Personal>(dto);

            _context.Personal.Add(personal);

            _context.SaveChanges();

            _logger.Log("Personal created!");

            return(_mapper.Map <PersonalReadDto>(personal));
        }
Esempio n. 5
0
        public ActionResult PutPersonal(int id, PersonalCreateDto dto)
        {
            var entity = _repository.Update(id, dto);

            return(Ok(entity));
        }
Esempio n. 6
0
        public ActionResult PostPersonal([FromBody] PersonalCreateDto dto)
        {
            var entity = _repository.Create(dto);

            return(Ok(entity));
        }