public ApiCommonController(ICategoryService categoryService,
                            IOfferStatusService offerStatusService,
                            IOfferService offerService,
                            IMessageService messageService)
 {
     _categoryService    = categoryService ?? throw new ArgumentNullException(nameof(categoryService));
     _offerStatusService = offerStatusService ?? throw new ArgumentNullException(nameof(offerStatusService));
     _offerService       = offerService ?? throw new ArgumentNullException(nameof(offerService));
     _messageService     = messageService ?? throw new ArgumentNullException(nameof(messageService));
 }
Esempio n. 2
0
        public static async Task InitData(ICategoryService categoryService, IOfferStatusService offerStatusService)
        {
            var categories = await categoryService.GetAll();

            var statuses = await offerStatusService.GetAll();

            if (categories.Count == 0)
            {
                var newCategories = new List <CategoryDto>
                {
                    new CategoryDto
                    {
                        Name = "Автомобили"
                    },
                    new CategoryDto
                    {
                        Name = "Бытовая техника"
                    },
                    new CategoryDto
                    {
                        Name = "Офисная техника"
                    },
                    new CategoryDto
                    {
                        Name = "Стройматериалы"
                    }
                };

                await categoryService.AddCollection(newCategories);
            }

            if (statuses.Count == 0)
            {
                var newStatuses = new List <OfferStatusDto>
                {
                    new OfferStatusDto
                    {
                        Amount = 2, Name = "Поднять на 2 позиции", Price = 100m
                    },
                    new OfferStatusDto
                    {
                        Amount = 5, Name = "Поднять на 5 позиций", Price = 200m
                    },
                    new OfferStatusDto
                    {
                        Amount = 10, Name = "Поднять на 10 позиций", Price = 400m
                    }
                };

                await offerStatusService.AddCollection(newStatuses);
            }
        }
 public OfferService(IUnitOfWork unitOfWork,
                     IMapper mapper,
                     ILogger <OfferService> logger,
                     ICustomerService customerService,
                     IOfferStatusService offerStatusService,
                     ICategoryService categoryService) : base(unitOfWork)
 {
     _mapper             = mapper ?? throw new ArgumentNullException(nameof(mapper));
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     _customerService    = customerService ?? throw new ArgumentNullException(nameof(customerService));
     _offerStatusService = offerStatusService ?? throw new ArgumentNullException(nameof(customerService));
     _categoryService    = categoryService ?? throw new ArgumentNullException(nameof(customerService));
 }