Example #1
0
        public async Task <IActionResult> ShareContact([FromBody] ShareDto shareDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var userEmail = HttpContextHelpers.GetCurrentUserEmail(User);
            var user      = await _userService.FindByEmailAsync(userEmail);

            var shareKardCommand = new ShareContactCommand(shareDto.ContactId, shareDto.RecipientUserId, user.Id);

            await _commandBus.Send(shareKardCommand);

            return(Ok());
        }
Example #2
0
        public List <SomeDataDto> SomeData()
        {
            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <Data.Contexts.Models.SomeData, SomeAggregate>();
                cfg.CreateMap <Color, string>().ConvertUsing(l => l.Value);
                cfg.CreateMap <FacebookUrl, string>().ConvertUsing(l => l.Value);
            });

            config.AssertConfigurationIsValid();
            var mapper = config.CreateMapper();

            var userEmail = HttpContextHelpers.GetCurrentUserEmail(User);
            var myData    = _someDataReadService.GetSomeData(userEmail);
            var someData  = mapper.Map <List <SomeAggregate>, List <SomeDataDto> >(myData);

            return(someData);
        }
Example #3
0
        public async Task <IActionResult> CreateSomeData([FromBody] CreateSomeDataDto createSomeDataModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var userEmail = HttpContextHelpers.GetCurrentUserEmail(User);
            var user      = await _userService.FindByEmailAsync(userEmail);

            var createCommand = new CreateSomeDataCommand(Guid.NewGuid(),
                                                          createSomeDataModel.FirstName,
                                                          createSomeDataModel.MiddleName,
                                                          createSomeDataModel.LastName,
                                                          createSomeDataModel.Title,
                                                          new Color(createSomeDataModel.Color),
                                                          DateTime.Now,
                                                          new FacebookUrl(createSomeDataModel.FacebookUrl),
                                                          new ApplicationUserId(user.Id));

            await _commandBus.Send(createCommand);

            return(Ok());
        }