示例#1
0
        /// <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("Неверный пароль или пользователь с такой почтой уже существует.");
            }
        }
示例#2
0
 /// <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;
 }
示例#3
0
 /// <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;
        }
示例#5
0
 /// <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");
     }
 }
示例#6
0
 /// <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");
     }
 }
示例#7
0
 /// <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");
     }
 }
示例#8
0
        /// <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;
        }
示例#9
0
        /// <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("Неверный пароль");
            }
        }
示例#10
0
        /// <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("Неверный пароль");
            }
        }
示例#11
0
 public RoomFotoService(IdentityUnitOfWork iuow)
 {
     _efUnitOfWork = iuow;
 }
示例#12
0
 public OrderService(IdentityUnitOfWork iuow)
 {
     _efUnitOfWork = iuow;
 }
示例#13
0
 public NoteService()
 {
     Database = IdentityUnitOfWork.Create();
 }
示例#14
0
 public RoleService(IdentityUnitOfWork efUnitOfWork)
 {
     _efUnitOfWork = efUnitOfWork;
 }
示例#15
0
 /// <summary>
 /// Provides CRUD functionality for roles.
 /// </summary>
 public RoleService(IdentityUnitOfWork identityUnitOfWork)
 {
     this.identityUnitOfWork = identityUnitOfWork ?? throw new ArgumentNullException(nameof(identityUnitOfWork));
 }
示例#16
0
 public UserProfileService()
 {
     _unitOfWork = new IdentityUnitOfWork();
 }
示例#17
0
 public AppUserService()
 {
     _unitOfWork = new IdentityUnitOfWork();
 }
示例#18
0
 public CustomerService(IdentityUnitOfWork iuow)
 {
     _efUnitOfWork = iuow;
 }
示例#19
0
 public UserService(IdentityUnitOfWork uow)
 {
     _efUnitOfWork = uow;
 }
示例#20
0
 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;
 }
示例#23
0
 public ServiceCreator(string connection)
 {
     database = new IdentityUnitOfWork(connection);
 }
示例#24
0
        public IService <GroupVisitorDTO> CreateGroupService(string connection)
        {
            IdentityUnitOfWork uow = new IdentityUnitOfWork(connection);

            return(new GroupService(uow));
        }