public void ShouldReturnValidWhenCreateCommandIsValid()
        {
            var command = new CreateEquipmentCommand();

            command.Description = "New Equipment";
            var result = _handler.Handle(command);

            Assert.AreEqual(true, result.Status);
        }
Пример #2
0
        public async Task <IActionResult> AddNewEquipment([FromBody] CreateEquipmentCommand createEquipmentCommand)
        {
            Logger.LogInformation("Sending command: {CommandName} - {IdProperty}: ({@Command})",
                                  createEquipmentCommand.GetGenericTypeName(), nameof(createEquipmentCommand), createEquipmentCommand);

            var equipmentId = await Mediator.Send(createEquipmentCommand);

            return(StatusCode(StatusCodes.Status201Created, equipmentId));
        }
        public Equipment Create(CreateEquipmentCommand command)
        {
            var equipment = new Equipment(command.IdTypeEquipment, command.Description, command.Model, command.SerialNumber, command.DateBuy, command.Patrimony);

            equipment.Create();
            _repository.Create(equipment);

            if (Commit())
            {
                return(equipment);
            }

            return(null);
        }
        public Task <HttpResponseMessage> Post([FromBody] dynamic body)
        {
            var command = new CreateEquipmentCommand(
                idTypeEquipment: (int)body.idTypeEquipment,
                description: (string)body.description,
                model: (string)body.model,
                serialNumber: (string)body.serialNumber,
                dateBuy: (DateTime)body.dateBuy,
                patrimony: (string)body.patrimony
                );

            var equipment = _service.Create(command);

            return(CreateResponse(HttpStatusCode.Created, equipment));
        }
Пример #5
0
 public void Create(CreateEquipmentCommand command)
 {
     _db.Connection().Execute(
         "spCreateEquipment",
         new
     {
         id           = command.Id,
         description  = command.Description,
         status       = command.Status,
         purchaseDate = command.PurchaseDate,
         idCollege    = command.IdCollege
     },
         commandType: CommandType.StoredProcedure
         );
 }
Пример #6
0
        public async Task <IActionResult> Post([FromBody] CreateEquipmentCommand command)
        {
            var result = _handler.Handle(command);

            return(await Response(result));
        }
Пример #7
0
 public ICommandResult Post([FromBody] CreateEquipmentCommand command)
 {
     return(_handler.Handle(command));
 }
 public void Create(CreateEquipmentCommand command)
 {
 }