public async Task <InstituteUserModel> RegisterNewDoctor([FromBody] ProviderModel model) { try { model.Password = GenericHelper.GenerateRandomPassword(8); var user = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; var currentProvider = await _providerManager.GetProviderDetails(user); model.InstituteId = currentProvider.InstituteId; model.FirstTimeSignInComplete = "N"; var provider = await _providerManager.RegisterNewProvider(model, currentProvider.ProviderId); string message = $"Dear {model.FirstName} {model.LastName},\n Your account has been created. Your temporary password is <b>{model.Password}</b>. Please login and update your details."; await _emailService.SendEmail(model.Email, message, "Welcome"); return(new InstituteUserModel { ProviderId = provider.ProviderId, RoomName = model.RoomName, CurrentRole = "doctor", Email = model.Email, Name = $"{model.FirstName} {model.LastName}" }); } catch (GenericException ex) { return(new InstituteUserModel { error = ex.Code }); } catch (Exception ex) { return(new InstituteUserModel { error = ex.Message, stackTrace = ex.StackTrace }); } }