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()); }
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); }
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()); }