Exemplo n.º 1
0
        public async Task <ICollection <LotRequest> > GetLotRequests(int lotId)
        {
            if (!await LotService.IsExist(lotId))
            {
                throw new EntityNotFoundException($"LotId:{lotId} not found", "Lot");
            }

            return(await Repository.GetByLot(lotId));
        }
Exemplo n.º 2
0
        public async Task <LotRequest> GetCurrentRequest(int lotId, int dispatcherId)
        {
            if (!await LotService.IsExist(lotId))
            {
                throw new EntityNotFoundException($"LotId:{lotId} not found", "Lot");
            }

            if (!await DispatcherService.IsExist(dispatcherId))
            {
                throw new EntityNotFoundException($"DispatcherId:{dispatcherId} not found", "Dispatcher");
            }

            return(await Repository.GetCurrent(lotId, dispatcherId));
        }
Exemplo n.º 3
0
        protected override async Task <bool> DoVerifyEntity(LotRequest entity)
        {
            if (!await LotService.IsExist(entity.LotId))
            {
                throw new EntityNotFoundException($"Owner LotId:{entity.LotId} not found", "Lot");
            }

            if (!await DispatcherService.IsExist(entity.DispatcherId))
            {
                throw new EntityNotFoundException($"Owner DispatcherId:{entity.DispatcherId} not found", "Dispatcher");
            }

            return(true);
        }
Exemplo n.º 4
0
        public async Task <bool> IsExistBet(int lotId, int dispatcherId)
        {
            if (!await LotService.IsExist(lotId))
            {
                throw new EntityNotFoundException($"LotId:{lotId} not found", "Lot");
            }

            if (!await DispatcherService.IsExist(dispatcherId))
            {
                throw new EntityNotFoundException($"DispatcherId:{dispatcherId} not found", "Dispatcher");
            }

            var currentRequest = await GetCurrentRequest(lotId, dispatcherId);

            return(currentRequest?.Status == LotRequestStatus.Bet);
        }
Exemplo n.º 5
0
        public async Task Trade(int orderId)
        {
            var lot = await LotService.GetByOrder(orderId);

            await LotService.Trade(lot.Id);

            var order = await OrderService.Get(orderId);

            var dispatchers = await DispatcherService.GetByCompany(order.CompanyId);

            var notify = new Notify(
                dispatchers,
                "Новый заказ",
                "Параметры нового заказа",
                NotificationChanelKind.All);
            await NotificationService.Notice(notify);
        }