public async Task CreateAsyncThrowsWithInvalidGender()
        {
            await this.SeedData();

            var input = new BaseInfoInputModel()
            {
                BirthDate = DateTime.Now,
                CountryId = 1,
                FirstName = "test",
                LastName  = "test",
                Gender    = "test",
            };

            await Assert.ThrowsAsync <ArgumentException>(() => this.profilesService.CreateAsync(input));
        }
        public async Task CreateAsyncWorskCorrectly()
        {
            await this.SeedData();

            var input = new BaseInfoInputModel()
            {
                BirthDate = DateTime.Now,
                CountryId = 1,
                FirstName = "test",
                LastName  = "test",
                Gender    = "Male",
            };

            var result = await this.profilesService.CreateAsync(input);

            Assert.Equal(2, result);
        }
Exemple #3
0
        public async Task <int> CreateAsync(BaseInfoInputModel input)
        {
            this.ValidateCountryId(input.CountryId);

            var gender = this.GetGender(input.Gender);

            var profile = new Profile()
            {
                BirthDate = input.BirthDate,
                FirstName = input.FirstName,
                LastName  = input.LastName,
                Gender    = gender,
                CountryId = input.CountryId,
            };

            await this.profileRepository.AddAsync(profile);

            await this.profileRepository.SaveChangesAsync();

            return(profile.Id);
        }