static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Console()
                         .WriteTo.File("logs\\log.txt", rollingInterval: RollingInterval.Day)
                         .CreateLogger();

            Log.Information("*****************************************************");
            Log.Information("Starting");

            ServiceMapper service = new ServiceMapper();

            //Replace values into class def
            Configuration cfg = new Configuration();

            try
            {
                service.DoWork(cfg);
                Log.Information("ENDs");
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Something went wrong");
            }
            finally
            {
                Log.Information("*****************************************************");
                Log.CloseAndFlush();
            }
        }
Example #2
0
        public List <Service> RetrieveAllByHotel(int idHotel)
        {
            try
            {
                ServiceMapper serviceMapper = new ServiceMapper();
                var           lstResult     = SqlDao.GetInstance()
                                              .ExecuteQueryProcedure(
                    serviceMapper.GetRetriveAllByIdStatement(idHotel)
                    );

                if (lstResult.Count <= 0)
                {
                    return(default(List <Service>));
                }

                var obj = EntityObjectMapper.BuildObjects(lstResult);

                return(obj.Cast <Service>().ToList());
            }
            catch (Exception e)
            {
                ManageException(e);
            }
            return(null);
        }
Example #3
0
        public static void ConfigureMapper(IMapperConfigurationExpression config)
        {
            config.CreateMap <TripCandidateModel, TripCandidate>();
            config.CreateMap <DestinationCandidateModel, DestinationCandidate>();
            config.CreateMap <PhotoSessionModel, PhotoSession>();
            config.CreateMap <HighliteTopicViewModel, HighliteTopic>();
            config.CreateMap <HighliteTopic, HighliteTopicViewModel>();
            config.CreateMap <HighliteItemViewModel, IHighliteItem>();
            config.CreateMap <IHighliteItem, HighliteItemViewModel>();

            ServiceMapper.ConfigureMapper(config);

            // to Album
            config.CreateMap <HighliteTopic, AlbumSectionViewModel>();
            config.CreateMap <Destination, AlbumSectionViewModel>();
            config.CreateMap <Location, AlbumSectionViewModel>();
            config.CreateMap <IHighliteItem, AlbumItemViewModel>();
            config.CreateMap <Photo, AlbumItemViewModel>();


            // from album service to VModel
            config.CreateMap <AlbumItem, AlbumItemViewModel>();
            config.CreateMap <AlbumItemViewModel, AlbumItem>();
            config.CreateMap <AlbumSection, AlbumSectionViewModel>();
            config.CreateMap <AlbumSectionViewModel, AlbumSection>();
            config.CreateMap <Album, AlbumViewModel>();
            config.CreateMap <AlbumViewModel, Album>();
        }
        public async Task <Dal.Entities.WareHouse> UpdateWareHouse(Dal.Entities.WareHouse warehouse)
        {
            Guard.Argument(warehouse, nameof(warehouse)).NotNull();

            await ValidateWareHouse(warehouse);

            var currentWareHouse = await GetWareHouseById(warehouse.Id);

            if (_unitOfWork.WareHouseRepository.GetAll().Any(w => w.Code.ToLower() == warehouse.Code.ToLower() &&
                                                             w.Id != warehouse.Id))
            {
                throw new ServiceException(new ErrorMessage[]
                {
                    new ErrorMessage()
                    {
                        Message = $"{warehouse.Code} is already exits"
                    }
                });
            }

            var mapper = ServiceMapper.GetMapper();

            mapper.Map(warehouse, currentWareHouse);

            await _unitOfWork.SaveChanges();

            return(currentWareHouse);
        }
Example #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            //Register ServiceMapper
            ServiceMapper.ConfigureServices(services, Configuration);
        }
        public async Task <Dal.Entities.Delivery> UpdateDelivery(Dal.Entities.Delivery delivery)
        {
            var currentDelivery = await GetDeliveryById(delivery.Id);

            if (currentDelivery.DeliveryStatus != DeliveryStatus.Pending)
            {
                throw new ServiceException(new ErrorMessage[]
                {
                    new ErrorMessage()
                    {
                        Message = "Unable update the delivery"
                    }
                });
            }

            var mapper = ServiceMapper.GetMapper();

            mapper.Map(delivery, currentDelivery);

            currentDelivery.DeliveryDate = delivery.DeliveryDate.Date;
            currentDelivery.Updated      = DateTimeOffset.UtcNow;

            await _unitOfWork.SaveChanges();

            return(currentDelivery);
        }
Example #7
0
        public async Task <ServiceResponse> Create(ServiceDTO newService)
        {
            var service = ServiceMapper.Map(newService);

            if (service.Name == null)
            {
                string errorMessage1 = "Service name not found.";
                Log.Error(errorMessage1);
                return(new ServiceResponse(errorMessage1));
            }
            if (service.Description == null)
            {
                string errorMessage2 = "Service description not found.";
                Log.Error(errorMessage2);
                return(new ServiceResponse(errorMessage2));
            }
            try
            {
                await _serviceRepository.Create(service);

                await _context.SaveChangesAsync();

                return(new ServiceResponse(ServiceMapper.Map(service)));
            }
            catch (Exception exception)
            {
                string errorMessage = $"An error occured when creating the item: {exception.Message}";
                return(new ServiceResponse(errorMessage));
            }
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader());
            });
            services.AddControllers();
            services.AddScoped <ICustomService, BuzzWordGenerator>();
            services.AddScoped <ICustomService, RandomDogGenerator>();
            services.AddScoped <ICustomService, CopyCatRepeater>();
            services.AddScoped <ICustomService, OpenDotaRetriever>();
            services.AddScoped <RestExecutioner>();
            services.AddScoped <IMessageProcessor, IncomingMessageProcessor>();
            services.AddHttpClient <TelegramService>();
            services.AddHttpClient <SlackService>();
            services.AddScoped <WhatsAppService>();

            // Feature Provider Library initial setup
            // services.AddFeatureProvider(Configuration);

            //
            // services.AddOptions();
            // services.Configure<ServicesSettings>(options => Configuration.GetSection("ServicesSettings").Bind(options));

            var servicesSettings = Configuration.GetSection("ServicesSettings").Get <ServicesSettings>();//Configuration.GetSection("Services").Get<Service[]>();

            ServiceMapper.Initialize(servicesSettings);
            // services.AddSingleton<ServicesSettings>(servicesSettings);
        }
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            RepositoryMapper repoMapper    = new RepositoryMapper();
            ServiceMapper    serviceMapper = new ServiceMapper();

            repoMapper.Map(kernel);
            serviceMapper.Map(kernel);
        }
Example #10
0
        public GetApartmentModel GetApartmentById(Guid id)
        {
            var apartment = Repository.Filter(a => a.Id == id, new [] { "Owner" }).FirstOrDefault();

            if (apartment == null)
            {
                throw new NotFoundException("Invalid apartment id");
            }

            return(ServiceMapper.Map <GetApartmentModel>(apartment));
        }
Example #11
0
        public void RegisterServicesMapper(IServiceCollection services)
        {
            var configExpression = ServiceMapper.GetMapperConfiguration(new string[]
            {
                "Users.Services",
                "Accounts.Services",
                "AccountsStatements.Services"
            });

            services.AddSingleton(configExpression);
            services.AddScoped <IServiceMapper, ServiceMapper>();
        }
        public async Task <Dal.Entities.Supplier> UpdateSupplier(Dal.Entities.Supplier supplier)
        {
            Guard.Argument(supplier, nameof(supplier)).NotNull();

            await ValidateSupplier(supplier);

            await using var transaction = await _unitOfWork.GetTransaction();

            try
            {
                var currentSupplier = await GetSupplierById(supplier.Id);

                supplier.TrackerCode = currentSupplier.TrackerCode;

                var mapper = ServiceMapper.GetMapper();
                mapper.Map(supplier, currentSupplier);

                await _unitOfWork.SaveChanges();

                var savedSupplier = await GetSupplierById(supplier.Id);

                await _trackerApiService.UpdateCustomerStatus(new UpdateCustomerRequest()
                {
                    Active       = supplier.Active ? "1" : "0",
                    CustomerCode = savedSupplier.TrackerCode,
                    StatusDate   = DateTime.Now,
                    StatusReason = "Update the supplier"
                });

                await transaction.CommitAsync();
            }
            catch (TrackingApiException ex)
            {
                await transaction.RollbackAsync();

                throw new ServiceException(new ErrorMessage[]
                {
                    new ErrorMessage()
                    {
                        Code    = string.Empty,
                        Message = $"Unable to create a supplier in tracker side"
                    }
                });
            }
            catch
            {
                await transaction.RollbackAsync();

                throw;
            }

            return(await GetSupplierById(supplier.Id));
        }
        /// <summary>
        /// Open account
        /// </summary>
        /// <param name="v">name</param>
        /// <param name="base">type</param>
        /// <param name="id">id</param>
        public void OpenAccount(decimal balance, decimal bonus, int id)
        {
            Account acc = new Account()
            {
                Id          = id,
                Balance     = balance,
                BonusPoints = bonus
            };

            unitOfWork.Accounts.AddAccount(ServiceMapper.Map(acc));
            ///to-do
        }
        /// <summary>
        /// Withdraw money
        /// </summary>
        /// <param name="id">Id</param>
        /// <param name="money">Money</param>
        public void WithdrawAccount(int id, decimal money)
        {
            var account = ServiceMapper.Map(unitOfWork.Accounts.GetAccount(id));

            if (money <= 0 || account == null)
            {
                throw new ArgumentException();
            }
            account.Balance     -= money;
            account.BonusPoints -= BonusPoints.GetBonusPoints("gold", money);
            unitOfWork.Accounts.UpdateAccount(ServiceMapper.Map(account));
        }
Example #15
0
        public override void Configure(MvvmConfiguration config)
        {
            base.Configure(config);

            ServiceMapper.RegisterObjects(config.IoC);

            Mapper.Initialize(
                cfg =>
            {
                ServiceMapper.ConfigureMapper(cfg);
                ConfigureMapper(cfg);
            });
        }
Example #16
0
        public async Task <ServiceResponse> GetById(int id)
        {
            var service = await _serviceRepository.GetById(id);

            if (service == null)
            {
                string errorMessage = "Service not found.";

                Log.Error(errorMessage);

                return(new ServiceResponse(errorMessage));
            }

            return(new ServiceResponse(ServiceMapper.Map(service)));
        }
Example #17
0
        public async Task <Dal.Entities.Product> UpdateProduct(Dal.Entities.Product product)
        {
            Guard.Argument(product, nameof(Product)).NotNull();

            await ValidateProduct(product);

            var currentProduct = await GetProductById(product.Id);

            var mapper = ServiceMapper.GetMapper();

            mapper.Map(product, currentProduct);

            await _unitOfWork.SaveChanges();

            return(currentProduct);
        }
Example #18
0
        public async Task <Dal.Entities.PurchaseOrder> UpdatePurchaseOrder(Dal.Entities.PurchaseOrder purchaseOrder)
        {
            Guard.Argument(purchaseOrder, nameof(purchaseOrder)).NotNull();

            await ValidatePurchaseOrder(purchaseOrder);

            var currentPurchaseOrder = await GetPurchaseOrderById(purchaseOrder.Id);

            var mapper = ServiceMapper.GetMapper();

            mapper.Map(purchaseOrder, currentPurchaseOrder);

            currentPurchaseOrder.Updated = DateTimeOffset.UtcNow;

            await _unitOfWork.SaveChanges();

            return(currentPurchaseOrder);
        }
Example #19
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            JwtModel model = GetJwtSettings();

            services.AddAuthentication(options => {
                options.DefaultAuthenticateScheme = "JwtBearer";
                options.DefaultChallengeScheme    = "JwtBearer";
            })
            .AddJwtBearer("JwtBearer", jwtBearerOptions => {
                jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(model.Key)),

                    ValidateIssuer = false,
                    ValidIssuer    = model.Issuer,

                    ValidateAudience = true,
                    ValidAudience    = model.Audience,

                    ValidateLifetime = true,
                    ClockSkew        = TimeSpan.FromMinutes(model.MinutesToExpiration)
                };
            });

            services.AddSingleton <JwtModel>(model);
            services.AddSingleton <MainDbUser>();


            RepositoryMapper repoMapper    = new RepositoryMapper();
            ServiceMapper    serviceMapper = new ServiceMapper();

            repoMapper.AddMappings(services);
            serviceMapper.AddMappings(services);


            services.AddSingleton <IConfiguration>(Configuration);
            services.AddCors();
            services.AddMvc();
        }
Example #20
0
 public static List <SeventyPercentClubEntryDto> MapToDto(this IList <SeventyPercentClubEntry> domains) => ServiceMapper.Map <List <SeventyPercentClubEntryDto> >(domains);
Example #21
0
 public SensorModel GetByApartmentId(Guid id)
 {
     return(ServiceMapper.Map <SensorModel>(Repository.Filter(s => s.ApartmentId == id).FirstOrDefault()));
 }
Example #22
0
        public async Task <Service> Update(Service service)
        {
            var data = await _serviceRepository.Update(ServiceMapper.Map(service));

            return(service);
        }
Example #23
0
        public async Task <Service> Get(int id)
        {
            var data = await _serviceRepository.Get(id);

            return(ServiceMapper.Map(data));
        }
Example #24
0
        public async Task <IActionResult> UpdateAdmin([FromBody] ServiceModel service)
        {
            var name = await _servicesService.UpdateService(ServiceMapper.Map(service));

            return(Ok(name));
        }
Example #25
0
        public async Task <Service> UpdateService(Service service)
        {
            var updated = await _servicesRepository.Update(ServiceMapper.Map(service));

            return(ServiceMapper.Map(updated));
        }
Example #26
0
        public async Task <Service> GetService(int id)
        {
            var entidad = await _servicesRepository.Get(id);

            return(ServiceMapper.Map(entidad));
        }
Example #27
0
        public async Task <Service> AddService(Service service)
        {
            var addedEntity = await _servicesRepository.Add(ServiceMapper.Map(service));

            return(ServiceMapper.Map(addedEntity));
        }
Example #28
0
 public List <ApartmentModel> GetAllApartments()
 {
     return(ServiceMapper.Map <List <ApartmentModel> >(Repository.GetAll()));
 }
Example #29
0
        public List <ApartmentModel> GetApartmentsByBuildingId(Guid buildingId)
        {
            var apartments = Repository.Filter(b => b.BuildingId == buildingId);

            return(ServiceMapper.Map <List <ApartmentModel> >(apartments));
        }
Example #30
0
        public ApartmentModel GetApartmentByOwnerId(Guid ownerId)
        {
            var apartment = Repository.Filter(a => a.OwnerId == ownerId).FirstOrDefault();

            return(ServiceMapper.Map <ApartmentModel>(apartment));
        }