/// <summary> /// Change email. /// </summary> /// <param name="email">Email</param> /// <param name="userId">Id</param> /// <param name="password">Password</param> /// <returns>Status</returns> public string ChangeEmail(string email, string userId, string password) { try { var user = IdentityUnitOfWork.UserManager.FindById(userId); var test = IdentityUnitOfWork.UserManager.FindByEmail(email); if (test == null && user != null && IdentityUnitOfWork.UserManager.CheckPassword(user, password)) { user.EmailConfirmed = false; user.Email = email; user.UserName = email; IdentityUnitOfWork.UserManager.Update(user); IdentityUnitOfWork.Save(); return(""); } else { return("Неверный пароль или пользователь с такой почтой уже существует."); } } catch (Exception e) { CreateLog(e, "AccountService", "ChangeEmail"); return("Неверный пароль или пользователь с такой почтой уже существует."); } }
/// <summary> /// Provides functionality for listing users and user role management. /// </summary> public UserService(IdentityUnitOfWork identityUnitOfWork) { if (identityUnitOfWork == null) { throw new ArgumentNullException(nameof(identityUnitOfWork)); } this.identityUnitOfWork = identityUnitOfWork; }
/// <summary> /// Unban user. /// </summary> /// <param name="userId">User id</param> public void UnbanUser(string userId) { try { IdentityUnitOfWork.UserManager.RemoveFromRole(userId, "banned"); IdentityUnitOfWork.Save(); } catch (Exception e) { CreateLog(e, "AdminService", "UnbanUserAsync"); } }
/// <summary> /// Provides functionality for registering, authenticating, updating user and role management. /// </summary> public AccountService(IdentityUnitOfWork identityUnitOfWork, EmployeeUnitOfWork employeeUnitOfWork) { if (identityUnitOfWork == null) { throw new ArgumentNullException(nameof(identityUnitOfWork)); } if (employeeUnitOfWork == null) { throw new ArgumentNullException(nameof(employeeUnitOfWork)); } this.identityUnitOfWork = identityUnitOfWork; this.employeeUnitOfWork = employeeUnitOfWork; }
/// <summary> /// Update information about client. /// </summary> /// <param name="profileDTO">New profile object</param> public void UpdateProfile(ProfileDTO profileDTO) { try { profileDTO.Id = profileDTO.User.Id; Profile profile = IdentityMapperDTO.ToProfile.Map <ProfileDTO, Profile>(profileDTO); profile.ApplicationUser = IdentityUnitOfWork.UserManager.FindById(profileDTO.User.Id); IdentityUnitOfWork.ClientManager.Update(profile); IdentityUnitOfWork.Save(); } catch (Exception e) { CreateLog(e, "ClientService", "UpdateProfileAsync"); } }
/// <summary> /// Confirm user email. /// </summary> /// <param name="userId">Id</param> public void ConfirmEmail(string userId) { try { var user = IdentityUnitOfWork.UserManager.FindById(userId); if (user != null) { user.EmailConfirmed = true; IdentityUnitOfWork.UserManager.Update(user); IdentityUnitOfWork.Save(); } } catch (Exception e) { CreateLog(e, "AccountService", "ConfirmEmailAsync"); } }
/// <summary> /// Ban user. /// </summary> /// <param name="userId">User id</param> public void BanUser(string userId) { try { var role = IdentityUnitOfWork.RoleManager.FindByName("banned"); if (role == null) { role = new ApplicationRole { Name = "banned" }; IdentityUnitOfWork.RoleManager.Create(role); } IdentityUnitOfWork.UserManager.AddToRole(userId, "banned"); IdentityUnitOfWork.Save(); } catch (Exception e) { CreateLog(e, "AdminService", "BanUserAsync"); } }
/// <summary> /// Provides functionality to list employees, find employees by search criteria, update employee related data. /// </summary> public EmployeeService(DomainUnitOfWork domain, EmployeeUnitOfWork employee, IdentityUnitOfWork identity) { if (domain == null) { throw new ArgumentNullException(nameof(domain)); } if (employee == null) { throw new ArgumentNullException(nameof(employee)); } if (identity == null) { throw new ArgumentNullException(nameof(identity)); } domainUnitOfWork = domain; employeeUnitOfWork = employee; identityUnitOfWork = identity; }
/// <summary> /// Change name. /// </summary> /// <param name="name">Name</param> /// <param name="userId">Id</param> /// <param name="password">Password</param> /// <returns>Status</returns> public string ChangeName(string name, string userId, string password) { try { var user = IdentityUnitOfWork.UserManager.FindById(userId); if (user != null && IdentityUnitOfWork.UserManager.CheckPassword(user, password)) { user.Name = name; IdentityUnitOfWork.UserManager.Update(user); IdentityUnitOfWork.Save(); return(""); } else { return("Неверный пароль."); } } catch (Exception e) { CreateLog(e, "AccountService", "ChangeName"); return("Неверный пароль"); } }
/// <summary> /// Change password. /// </summary> /// <param name="userId">Id</param> /// <param name="password">Password</param> /// <returns>Status</returns> public string ChangePassword(string userId, string password) { try { var user = IdentityUnitOfWork.UserManager.FindById(userId); if (user != null) { IdentityUnitOfWork.UserManager.RemovePassword(userId); IdentityUnitOfWork.UserManager.AddPassword(userId, password); IdentityUnitOfWork.Save(); return(""); } else { return("Неверный пароль."); } } catch (Exception e) { CreateLog(e, "AccountService", "ChangeName"); return("Неверный пароль"); } }
public RoomFotoService(IdentityUnitOfWork iuow) { _efUnitOfWork = iuow; }
public OrderService(IdentityUnitOfWork iuow) { _efUnitOfWork = iuow; }
public NoteService() { Database = IdentityUnitOfWork.Create(); }
public RoleService(IdentityUnitOfWork efUnitOfWork) { _efUnitOfWork = efUnitOfWork; }
/// <summary> /// Provides CRUD functionality for roles. /// </summary> public RoleService(IdentityUnitOfWork identityUnitOfWork) { this.identityUnitOfWork = identityUnitOfWork ?? throw new ArgumentNullException(nameof(identityUnitOfWork)); }
public UserProfileService() { _unitOfWork = new IdentityUnitOfWork(); }
public AppUserService() { _unitOfWork = new IdentityUnitOfWork(); }
public CustomerService(IdentityUnitOfWork iuow) { _efUnitOfWork = iuow; }
public UserService(IdentityUnitOfWork uow) { _efUnitOfWork = uow; }
private IIdentityUnitOfWork Create() { return(IdentityUnitOfWork.Create("RezhCityConnection")); }
public GenderRepository(IdentityUnitOfWork <ApplicationDbContext, User, Role> identityUnitOfWork, ApplicationDbContext applicationDbContext) { _identityUnitOfWork = identityUnitOfWork; _applicationDbContext = applicationDbContext; }
public PersistGrantsRepository(IdentityUnitOfWork <ApplicationDbContext, User, Role> identityUnitOfWork, ApplicationDbContext applicationDbContext) { _identityUnitOfWork = identityUnitOfWork; _applicationDbContext = applicationDbContext; }
public ServiceCreator(string connection) { database = new IdentityUnitOfWork(connection); }
public IService <GroupVisitorDTO> CreateGroupService(string connection) { IdentityUnitOfWork uow = new IdentityUnitOfWork(connection); return(new GroupService(uow)); }