private async Task <(string, string)> SeedTwoUsers() { var dto = new UserAddUpdRequest { FirstName = "Homer", LastName = "Simpson" }; var homerId = (await _userCmdService.Create(dto)).Value.Id !; dto.FirstName = "Marge"; var margeId = (await _userCmdService.Create(dto)).Value.Id !; await SaveChanges(); return(homerId, margeId); }
private async Task <string> SeedCurrentUsers() { var dto = new UserAddUpdRequest { FirstName = "Homer", LastName = "Simpson" }; var homer = await _userCmdService.Create(dto); if (!homer.IsSuccess) { throw new Exception("Failed to create a user for Homer"); } await SaveChanges(); return(homer.Value.Id !); }
private async Task <(string, string)> SeedTwoUsers() { var dto = new UserAddUpdRequest { FirstName = "Homer", LastName = "Simpson" }; var homer = await _userCmdService.Create(dto); if (!homer.IsSuccess) { throw new Exception("Failed to create a user for Homer"); } dto.FirstName = "Marge"; var marge = await _userCmdService.Create(dto); if (!marge.IsSuccess) { throw new Exception("Failed to create a user for Marge"); } await SaveChanges(); return(homer.Value.Id !, marge.Value.Id !); }
private async Task <UserReference> CreateSampleUser() { var dto = new UserAddUpdRequest { FirstName = "Homer", LastName = "Simpson" }; var userAdded = await _userCommandService.Create(dto); if (!userAdded.IsSuccess) { throw new Exception("Failed to create a user"); } await SaveChanges(); return(userAdded.Value); }
private async Task <UserReference> CreateSampleUser() { var dto = new UserAddUpdRequest { FirstName = SampleFirstName, LastName = SampleLastName, Email = SampleEmail }; var userAddedRes = await _userCommandService.Create(dto); if (!userAddedRes.IsSuccess) { throw new System.Exception("Can't create a user"); } await SaveChanges(); return(userAddedRes.Value); }
private async Task <UserReference> CreateUser(string firstName, string lastName, string email) { var dto = new UserAddUpdRequest { FirstName = firstName, LastName = lastName, Email = email }; var userAddedRes = await _userCommandService.Create(dto); if (!userAddedRes.IsSuccess) { throw new System.Exception($"Can't create '{firstName} {lastName}' user"); } await SaveChanges(); return(userAddedRes.Value); }
public async Task <IList <UserReference> > GetGeneratedUsers() { if (_userRefs.Count > 0) { return(_userRefs); } for (var i = 0; i < UserQuantity; i++) { var dto = _userFaker.Generate(); var resp = await _userService.Create(dto); if (!resp.IsSuccess) { throw new Exception("Failed to create a new user"); } _userRefs !.Add(resp.Value); } return(_userRefs !); }
public async Task <string> AddUser(string companyId, string projectId, string email) { var company = await _companyRepository.GetFirstOrDefault(companyId) ?? throw new Exception($"No Company found against id:'{companyId}'"); var project = company.GetProject(projectId) ?? throw new Exception($"No Project found against id:'{projectId}'"); var user = company.GetUserByEmail(email); if (user is null) { await _userCommandService.Create(companyId, new CreateUserVm { Email = email }); user = company.GetUserByEmail(email); } project.AddUsers(new List <Core.Model.User> { user }); await _companyRepository.SaveChanges(); return(project.Id); }
public async Task <string> Add([GraphQLSession] AuthSession session, [Service] IUserCommandService service, CreateUserVm model) { return(Ok(await service.Create(session.CompanyId, model))); }
public Task <ActionResult <UserReference> > Create([FromServices] IUserCommandService service, UserAddUpdRequest dto) => service.Create(dto).ToActionResultOfT();