예제 #1
0
 private void MapViewModelsToCommands()
 {
     this.CreateMap <InviteUserViewModel, InviteUserCommand>()
     .ConstructUsing(source =>
                     new InviteUserCommand(LocationId.With(Guid.Parse(source.Id)), new Email(source.Email)));
     this.CreateMap <DeleteInvitationViewModel, DeleteInvitationCommand>()
     .ConstructUsing(source => new DeleteInvitationCommand(LocationId.With(Guid.Parse(source.Id)),
                                                           InvitationId.With(Guid.Parse(source.Invitation))));
 }
예제 #2
0
 private void MapViewModelsToCommands()
 {
     this.CreateMap <AddLocationViewModel, AddLocationCommand>()
     .ConstructUsing(source => new AddLocationCommand(LocationId.NewComb(), source.Name, source.Address,
                                                      new Latitude(source.Latitude), new Longitude(source.Longitude), source.PricePerKw));
     this.CreateMap <EditLocationViewModel, EditLocationCommand>()
     .ConstructUsing(source => new EditLocationCommand(LocationId.With(Guid.Parse(source.Id)), source.Name,
                                                       source.Address, new Latitude(source.Latitude), new Longitude(source.Longitude), source.PricePerKw));
     this.CreateMap <DeleteLocationViewModel, DeleteLocationCommand>()
     .ConstructUsing(source => new DeleteLocationCommand(LocationId.With(Guid.Parse(source.Id))));
 }
예제 #3
0
        public async Task <IActionResult> RejectInvitation([CustomizeValidator(Skip = true)][FromBody]
                                                           RejectInvitationViewModel model)
        {
            ValidationResult validationResults = await this.rejectInvitationValidator
                                                 .ValidateAsync(model ?? new RejectInvitationViewModel(), CancellationToken.None).ConfigureAwait(false);

            validationResults.AddToModelState(this.ModelState, null);

            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            Location location = await this.GetLocationByInvitationCode(model?.Code.ToString(), CancellationToken.None)
                                .ConfigureAwait(false);

            if (location == null)
            {
                this.ModelState.AddModelError("Code", LocationResources.InvitationNotFound);
                return(this.BadRequest(this.ModelState));
            }

            IExecutionResult result = await this.commandBus
                                      .PublishAsync(
                new RejectInvitationCommand(LocationId.With(Guid.Parse(location.Id)),
                                            InvitationId.With(Guid.Parse(model.Code.ToString()))), CancellationToken.None)
                                      .ConfigureAwait(false);

            if (!result.IsSuccess)
            {
                return(this.BadRequest());
            }

            return(this.Ok(await this.GetInvitationByCode(location.Id, model.Code.ToString(), CancellationToken.None)
                           .ConfigureAwait(false)));
        }
예제 #4
0
 public UserIsLocationOwner(string id)
 {
     this.Id = LocationId.With(Guid.Parse(id)).Value;
 }
 public LocationWithNameDoesNotExist(string name, string exceptId = null)
 {
     this.Name     = name;
     this.ExceptId = string.IsNullOrWhiteSpace(exceptId) ? null : LocationId.With(Guid.Parse(exceptId)).Value;
 }
예제 #6
0
 public LocationById(string id)
 {
     this.Id = LocationId.With(Guid.Parse(id)).Value;
 }
예제 #7
0
 public InvitationByRecipient(string location, string email)
 {
     this.Location = LocationId.With(Guid.Parse(location)).Value;
     this.Email    = email;
 }
예제 #8
0
 public InvitationsForLocation(string id)
 {
     this.Id = LocationId.With(Guid.Parse(id)).Value;
 }
 public InvitationForEmailDoesNotExist(string location, string email)
 {
     this.Location = LocationId.With(Guid.Parse(location)).Value;
     this.Email    = email;
 }
예제 #10
0
 public LocationsByIds(List <string> ids)
 {
     this.Ids = ids?.Select(id => LocationId.With(Guid.Parse(id)).Value).Distinct().ToList() ??
                new List <string>();
 }
예제 #11
0
 public InvitationById(string location, string invitation)
 {
     this.Location   = LocationId.With(Guid.Parse(location)).Value;
     this.Invitation = InvitationId.With(Guid.Parse(invitation)).Value;
 }