Ejemplo n.º 1
0
 public Task <object> Handle(AddNewPreservationCommand command, CancellationToken cancellationToken)
 {
     Entities.Preservation u = new Entities.Preservation(null, new Description(command.Description));
     if (!command.IsValid())
     {
         NotifyValidationErrors(command);
     }
     else
     {
         PreservationModel model = _PreservationRepository.Add(u);
         if (model != null)
         {
             return(Task.FromResult(model as object));
         }
         _bus.RaiseEvent(new DomainNotification("Preservation", "Server error", NotificationCode.Error));
     }
     return(Task.FromResult(null as object));
 }
Ejemplo n.º 2
0
        public Task <AddNewPreservationResponse> addNewPreservation(AddNewPreservationRequest request)
        {
            AddNewPreservationCommand command      = new AddNewPreservationCommand(request.Description);
            Task <object>             Preservation = (Task <object>)Bus.SendCommand(command);
            //RabbitMQBus.Publish(command);
            AddNewPreservationResponse response = new AddNewPreservationResponse();

            response = Common <AddNewPreservationResponse> .checkHasNotification(_notifications, response);

            response.OK = false;
            if (response.Success)
            {
                PreservationModel PreservationModel = (PreservationModel)Preservation.Result;
                response.Content = PreservationModel.ID;
                response.OK      = true;
            }
            return(Task.FromResult(response));
        }