public async Task <IActionResult> Post(AnimalRequestDto animalDto)
        {
            var animal = mapper.Map <AnimalRequestDto, Animal>(animalDto);
            await animalRepository.AddAnimal(animal);

            var animalresponseDto = mapper.Map <Animal, AnimalResponseDto>(animal);

            return(Ok(animalresponseDto));
        }
示例#2
0
        public async Task <IActionResult> Post(AnimalRequestDto animalDto)
        {
            var animal = _mapper.Map <AnimalRequestDto, Animal>(animalDto);
            await _service.AddAnimal(animal);

            var animalresponseDto = _mapper.Map <Animal, AnimalResponseDto>(animal);
            var response          = new ApiResponse <AnimalResponseDto>(animalresponseDto);

            return(Ok(response));
        }
示例#3
0
        public IActionResult Put(int id, AnimalRequestDto animalDto)
        {
            var animal = _mapper.Map <Animal>(animalDto);

            animal.Id        = id;
            animal.UpdateAt  = DateTime.Now;
            animal.UpdatedBy = 2;
            _service.UpdateAnimal(animal);
            var response = new ApiResponse <bool>(true);

            return(Ok(response));
        }
        public async Task <IActionResult> Put(int id, AnimalRequestDto animalDto)
        {
            var animal = _mapper.Map <Animal>(animalDto);

            animal.Id        = id;
            animal.UpdateAt  = DateTime.Now;
            animal.UpdatedBy = 2;
            var result = await _repository.UpdateAnimal(animal);

            var response = new ApiResponse <bool>(result);

            return(Ok(response));
        }
示例#5
0
        public AnimalDto Add(AnimalRequestDto model)
        {
            if (model == null)
            {
                return(null);
            }

            Animal animal = new Animal()
            {
                Name   = model.Name?.Trim(),
                Type   = model.Type,
                UserId = _userId
            };

            _uow.AnimalRepository.Create(animal);

            return(_mapper.Map <AnimalDto>(animal));
        }
        public async Task <IActionResult> Post(AnimalRequestDto animalDto, string Correo, string CorreoCop, string UrlFirma)

        {
            System.Net.Mail.MailMessage mssg = new System.Net.Mail.MailMessage();
            mssg.To.Add(Correo);
            mssg.Subject         = "Firma Documento";
            mssg.SubjectEncoding = System.Text.Encoding.UTF8;
            mssg.Bcc.Add(CorreoCop);//para que le llegue copia a alguien
            mssg.Body         = "Ingresa a siguiente enlace para firmar " + UrlFirma;
            mssg.BodyEncoding = System.Text.Encoding.UTF8;
            mssg.IsBodyHtml   = true;
            mssg.From         = new System.Net.Mail.MailAddress("*****@*****.**");


            System.Net.Mail.SmtpClient cliente = new System.Net.Mail.SmtpClient();
            cliente.Credentials = new System.Net.NetworkCredential("*****@*****.**", "ingrid1234");//remitente
            cliente.Port        = 587;
            cliente.EnableSsl   = true;
            cliente.Host        = "smtp.gmail.com";
            try
            {
                cliente.Send(mssg);

                // MessageBox.Show("Cita Cancelada y se envio correo de notificacion.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                return(Ok(ex.Message));
                // MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }



            var animal = _mapper.Map <AnimalRequestDto, Animal>(animalDto);
            await _service.AddAnimal(animal);

            var animalresponseDto = _mapper.Map <Animal, AnimalResponseDto>(animal);
            var response          = new ApiResponse <AnimalResponseDto>(animalresponseDto);

            return(Ok(response));
        }
示例#7
0
 public AnimalDto Post(AnimalRequestDto model)
 {
     return(_animalService.Add(model));
 }