public void Execute(Message msg, IMessageSenderService sender, IBot bot)
        {
            if (StaticContent.UsersCommand.Any(u => u.Key == msg.MessageVK.FromId))
            {
                var command = StaticContent.UsersCommand.SingleOrDefault(u => u.Key == msg.MessageVK.FromId);
                StaticContent.UsersCommand.Remove(msg.MessageVK.FromId.Value);

                if (command.Value == "addAdsPartTwo")
                {
                    AdvertisementAddCommand.AddPartTwo(msg.MessageVK.FromId.Value, msg.ChatId, sender, msg.Text, bot);
                }
                else if (command.Value == "addcarinfo")
                {
                    AddCarCommand.AddCarInfo(sender, msg.ChatId, msg.Text);
                }
                else if (command.Value == "target")
                {
                    TargetEditCommand.Edited(msg, sender, bot);
                }
                else if (command.Value == "search")
                {
                    SearchCommand.Search(msg, sender, bot);
                }
            }
            else
            {
                sender.Text("⛔ Неизвестная команда", msg.ChatId);
            }
        }
        public void GetCommandNameTest()
        {
            Vehicle       vehicle     = new Vehicle();
            AddCarCommand addCarCmd   = new AddCarCommand(vehicle);
            string        commandName = addCarCmd.CommandName;

            Assert.AreEqual(commandName, addCarCmd.CommandName);
        }
        public void AddCarCommand()
        {
            Vehicle       v     = new Vehicle();
            AddCarCommand aD    = new AddCarCommand(v);
            var           aType = aD.GetType();

            Assert.IsInstanceOfType(aD, aType);
        }
        public void ExecuteTest()
        {
            Vehicle       v  = new Vehicle();
            AddCarCommand aD = new AddCarCommand(v);

            CommandHistory.ExecuteCommand(aD);
            Assert.IsNotNull(CommandHistory.PeekInStack(CommandHistory.StackTypes.UNDO));
            Assert.IsNull(CommandHistory.PeekInStack(CommandHistory.StackTypes.REDO));
        }
Example #5
0
 public CarsViewModel()
 {
     CurrentModel            = new CarsModel();
     Cars                    = new ObservableCollection <Car>(CurrentModel.Cars);
     Cars.CollectionChanged += Cars_CollectionChanged;
     //AddCar = new AddCarCommand(this);
     AddCar           = new AddCarCommand();
     AddCar.CarAdded += AddCar_CadAdded;
 }
        public void ExecuteTest()
        {
            Vehicle       v  = new Vehicle();
            AddCarCommand aD = new AddCarCommand(v);

            aD.Execute();
            Vehicle v2 = DBController.GetByPrimaryKey <Vehicle>(v.PrimaryKey);

            Assert.IsNotNull(v2);
        }
Example #7
0
        public async Task <ApiResponse> SaveCar(AddCarCommand command)
        {
            try
            {
                var response = await _mediator.Send(command);

                return(new ApiResponse(response, 201));
            }
            catch (Exception ex)
            {
                return(new ApiResponse(ex.Message, 400));
            }
        }
        public async Task <AddCarCommandResult> AddCarAsync(AddCarDto car)
        {
            var command = new AddCarCommand
            {
                Brand          = car.Brand,
                Mileage        = car.Mileage,
                Model          = car.Model,
                ProductionDate = car.ProductionDate,
                PhotoNames     = car.Photos.Select(x => x.FileName).ToList()
            };
            var result = await _mediator.Send(command);

            _fileService.SavePhotos(
                car.Photos,
                result.CarId);

            return(result);
        }
Example #9
0
        public async Task <ActionResult <AddCarResponseDto> > AddCar([FromBody] AddCarRequestDto addCarRequestDto)
        {
            AddCarCommand addCarCommand = new AddCarCommand
            {
                Manufacture   = addCarRequestDto.Manufacture,
                Model         = addCarRequestDto.Model,
                Year          = addCarRequestDto.Year,
                Vin           = addCarRequestDto.Vin,
                Description   = addCarRequestDto.Description,
                Observation   = addCarRequestDto.Observation,
                CarGroupId    = addCarRequestDto.CarGroupId,
                StandardPrice = addCarRequestDto.StandardPrice,
                IsAvailable   = addCarRequestDto.IsAvailable,
                DateCreated   = DateTime.UtcNow,
                CreatedBy     = "admin"
            };

            return(await Mediator.Send(addCarCommand));
        }
Example #10
0
        public async Task <Car> AddCar(AddCarCommand addCarCommand)
        {
            Car car = new Car
            {
                Manufacture   = addCarCommand.Manufacture,
                Model         = addCarCommand.Model,
                Year          = addCarCommand.Year,
                Vin           = addCarCommand.Vin,
                Description   = addCarCommand.Description,
                IsAvailable   = addCarCommand.IsAvailable,
                CarGroupId    = addCarCommand.CarGroupId,
                Observation   = addCarCommand.Observation,
                StandardPrice = addCarCommand.StandardPrice,
                DateCreated   = addCarCommand.DateCreated,
                CreatedBy     = addCarCommand.CreatedBy
            };
            await _dbContext.AddAsync(car);

            await _dbContext.SaveChangesAsync();

            return(car);
        }
Example #11
0
        public async Task <IActionResult> Add(AddCarCommand addCarCommand)
        {
            var rs = await _mediator.Send(addCarCommand);

            return(rs != null?Ok(rs) : NotFound());
        }