public async Task <ICommandResult> Handle(CharacteristicUpdateCommand command) { //FFV command.Validate(); if (command.Invalid) { return(new GenericCommandResult( false, HttpStatusCode.BadRequest, command.Notifications)); } var _verify = await _characteristicRepository.FindById(command.Id); if (_verify == null) { return(new GenericCommandResult(false, HttpStatusCode.NotFound, "Não localizado na base")); } Characteristic _entity = new Characteristic(); _entity.Id = command.Id; _entity.Description = command.Description; _entity.CategoryId = command.CategoryId; var _result = await _cudRepository.Update(_entity); //retorna o resultado if (!_result) { return(new GenericCommandResult(false, HttpStatusCode.BadRequest, _result)); } return(new GenericCommandResult(true, HttpStatusCode.OK, _result)); }
public async Task <ICommandResult> Handle(ManufacturerUpdateCommand command) { //FFV command.Validate(); if (command.Invalid) { return(new GenericCommandResult( false, HttpStatusCode.BadRequest, command.Notifications)); } var _verify = await _manufactoryRepository.FindById(command.Id); if (_verify == null) { return(new GenericCommandResult(false, HttpStatusCode.NotFound, "Não localizado na base")); } Manufacturer _entity = new Manufacturer(command.Id, command.Description); var _result = await _cudRepository.Update(_entity); //retorna o resultado if (!_result) { return(new GenericCommandResult(false, HttpStatusCode.BadRequest, _result)); } return(new GenericCommandResult(true, HttpStatusCode.OK, _result)); }
public async Task <ICommandResult> Handle(UserUpdateCommand command) { //FFV command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, HttpStatusCode.BadRequest, command.Notifications)); } var _verify = await _userRepository.FindById(command.Id); if (_verify == null) { return(new GenericCommandResult(false, HttpStatusCode.NotFound, "Não localizado na base")); } User _entity = new User(); _entity.Id = command.Id; _entity.Login = _verify.Login; _entity.Password = command.Password; _entity.Name = command.Name; _entity.Role = (!string.IsNullOrEmpty(command.Role)) ? command.Role : "Administrator"; var _result = await _cudRepository.Update(_entity); //retorna o resultado if (!_result) { return(new GenericCommandResult(false, HttpStatusCode.BadRequest, _result)); } return(new GenericCommandResult(true, HttpStatusCode.OK, _result)); }