Example #1
0
        public async Task <ServiceResult> RegisterMuseumAsync(MuseumRegistrationModel model)
        {
            var museum = new Museum
            {
                Name = model.MuseumName,
            };

            await museumRepository.CreateAsync(museum);

            var user = new ApplicationUser
            {
                UserName = model.Username,
                Email    = model.Email,
                Museum   = museum,
            };

            var identityResult = await userManager.CreateAsync(user, model.Password);

            if (identityResult.Succeeded)
            {
                await emailConfirmationService.SendConfirmationEmailAsync(user, "");

                return(ServiceResult <ApplicationUser> .Success(user));
            }

            var serviceErrors = identityResult.Errors.Select(error => new ServiceError {
                Code = error.Code, Description = error.Description
            });

            return(ServiceResult.Failed(serviceErrors.ToArray()));
        }