示例#1
0
 public ProfileSettingsViewModel(SettingsController controller)
     : base("PROFILES", controller)
 {
     RemoveProfileCommand = new ReactiveCommand(SelectedProfile.Select(i => i != null), false);
     RemoveProfileCommand.Subscribe(OnRemoveProfile);
     AddProfileCommand.Subscribe(OnAddProfile);
 }
        public async Task <IActionResult> Post([FromBody] AddProfileCommand addProfileCommand)
        {
            var response = await _mediator.Send(addProfileCommand, Request.HttpContext.RequestAborted);

            if (response.IsValid)
            {
                return(Ok(response));
            }
            return(BadRequest(response));
        }
        public void Register(string routingKey, AddProfileCommand command)
        {
            //If it get complex I will add some routingKey switch
            // and work with ICommand
            _consumer.Received += async(model, ea) =>
            {
                var userInfo = ObjectConverter.ByteToObject <UserInsertDTO>(ea.Body);

                command.UserInfo = userInfo;
                await _commandBus.SubmitAsync(command);
            };
        }
        public EditOrDeleteObstacleViewModel()
        {
            LeaveOnlySelectedObstacleCommand = new LeaveOnlySelectedObstacleCommand(this);
            AddProfileCommand = new AddProfileCommand(this);
            RemoveProfileCommand = new RemoveProfileCommand(this);
            EditObstacleCommand = new EditObstacleCommand(this);
            RemoveObstacleCommand = new RemoveObstacleCommand(this);

            GetObstacles();

            var obst = Obstacles.First();
            obst.IsSelected = true;
            SelectedObstacle = obst;
        }
        public ObstacleCreatorViewModel()
        {
            AddObstacleCommand = new AddObstacleCommand(this);
            AddProfileCommand = new AddProfileCommand(this);
            RemoveProfileCommand = new RemoveProfileCommand(this);

            if (Colors.Any())
            {
                SelectedColor = Colors.First();
                IsSelected = true;
            }
            else
            {
                IsSelected = false;
            }
        }
示例#6
0
        public async Task <IActionResult> Registration(
            [FromServices] IMediator mediator,
            [FromBody] RegistrationDto registrationDto)
        {
            var query       = new GetProfileByLoginQuery(registrationDto.ProfileDto.Login);
            var resultQuery = await mediator.Send(query);

            if (resultQuery.Profile != null)
            {
                return(ValidationProblem("Login exists"));
            }

            var command = new AddProfileCommand(registrationDto.ProfileDto, registrationDto.Password);

            var data = await mediator.Send(command);

            return(new JsonResult(data.Profile));
        }
示例#7
0
        public async Task <Result <PatientHeiProfile> > Handle(AddProfileCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    await _unitOfWork.Repository <PatientHeiProfile>().AddAsync(request.PatientHeiProfile);

                    await _unitOfWork.SaveAsync();

                    var ret = request.PatientHeiProfile;
                    return(Result <PatientHeiProfile> .Valid(request.PatientHeiProfile));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message + " " + e.InnerException);
                    return(Result <PatientHeiProfile> .Invalid(e.Message));
                }
            }
        }
示例#8
0
 public ProfileVM()
 {
     ProfileModel         = new ProfileModel();
     AddProfile           = new AddProfileCommand(this);
     CancelProfileCommand = new CancelProfileCommand();
 }
示例#9
0
        public async Task <IActionResult> PostAsync(AddProfileCommand req)
        {
            var result = await _mediator.Send(req);

            return(Ok(result));
        }