public async Task<Esthetician> AddEstheticianAsync(AddEstheticianViewModel model) { var user = _mapper.Map<ApplicationUser>(model); var result = await _userManager.CreateAsync(user, "$ugar4me"); if (!result.Succeeded) //TODO: Logging! return null; var esth = new Esthetician { ApplicationUserId = user.Id }; var roleResult = _userManager.AddToRoleAsync(user, "Esthetician").Result; return _estheticians.AddAsync(esth).Result; }
private static void AddEstheticians(UserManager<ApplicationUser> users, RoleManager<ApplicationRole> roles, SMDbContext context) { var esthUser = users.FindByEmailAsync("*****@*****.**").Result; var allServices = context.SpaServices.ToList(); var esthetician = new Esthetician { ApplicationUserId = esthUser.Id, Services = allServices.OrderBy(x => x.Id).Take(12).ToList(), Color = "33cc33" }; context.Estheticians.Add(esthetician); var nextUser = users.FindByEmailAsync("*****@*****.**").Result; var nextEsth = new Esthetician { ApplicationUserId = nextUser.Id, Services = allServices.ToList(), Color = "cc33ff" }; context.Estheticians.Add(nextEsth); context.SaveChanges(); }