Ejemplo n.º 1
0
        public async Task <UserTripsDto> CreateAsync(UserTripsDto usertripsdto)
        {
            Mapper.Reset();
            Mapper.Initialize(cfg => cfg.CreateMap <UserTripsDto, UserTrips>());
            var entity = Mapper.Map <UserTripsDto, UserTrips>(usertripsdto);

            _context.UserTrips.Add(entity);
            await _context.SaveChangesAsync();

            Mapper.Reset();
            Mapper.Initialize(cfg => cfg.CreateMap <UserTrips, UserTripsDto>());
            var result = Mapper.Map <UserTrips, UserTripsDto>(entity);

            return(result);
        }
Ejemplo n.º 2
0
        public async Task <BusinessResult <UserTripsDto> > SaveProcess(int document, string urlProcess)
        {
            try
            {
                var userTripsDto = new UserTripsDto()
                {
                    Document       = document,
                    DateProcess    = System.DateTime.Now,
                    UrlFileProcess = urlProcess
                };
                var result = await _iusertripsdata.CreateAsync(userTripsDto);

                return(BusinessResult <UserTripsDto> .Success(result, "Operación Correcta"));
            }
            catch (Exception ex)
            {
                return(BusinessResult <UserTripsDto> .Issue(null, "Operación Incorrecta", ex));
            }
        }