public ProcurementRoleProvider(IUnitOfWorkAsync unitOfWorkAsync, IServiceRole serviceRole, IServiceUser serviceUser) { this.unitOfWorkAsync = unitOfWorkAsync; this.serviceRole = serviceRole; this.serviceUser = serviceUser; }
public override string[] GetRolesForUser(string email) { IServiceRole serviceRole = DependencyResolver.Current.GetService <ServiceRole>(); IServiceUser serviceUser = DependencyResolver.Current.GetService <ServiceUser>(); User user = serviceUser.GetByEmail(email); string[] roles = user.Roles.Select(r => r.Name).ToArray(); return(roles); }
public ApplicationServiceAccount ( IServiceUser serviceUser, IServiceRole serviceRole, IServiceRegister serviceRegister, IApplicationServiceMD5 md5Service, IMapper mapper ) { _serviceUser = serviceUser; _serviceRole = serviceRole; _serviceRegister = serviceRegister; _md5Service = md5Service; _mapper = mapper; }
public RoleController() { this._iServiceRole = new ServiceRole(); }
public UserController() { this._iServiceUser = new ServiceUser(); this._iServiceRole = new ServiceRole(); }
public ServiceAppRole(IServiceRole serviceRole) : base(serviceRole) { }
public ActionResult Registre(Models.UserRegistreViewModel userRegistreViewModel) { if (!this.ModelState.IsValid) { return(View()); } #region Server Side Validation bool modelStateFail = false; if (string.IsNullOrEmpty(userRegistreViewModel.Name)) { this.ModelState.AddModelError("Name", "Name field is required!"); modelStateFail = true; } if (string.IsNullOrEmpty(userRegistreViewModel.Login)) { this.ModelState.AddModelError("Login", "Login field is required!"); modelStateFail = true; } if (string.IsNullOrEmpty(userRegistreViewModel.Password)) { this.ModelState.AddModelError("Password", "Password field is required!"); modelStateFail = true; } if (string.IsNullOrEmpty(userRegistreViewModel.PasswordConfirm)) { this.ModelState.AddModelError("PasswordConfirm", "Confirm password field is required!"); modelStateFail = true; } if (string.IsNullOrEmpty(userRegistreViewModel.Email)) { this.ModelState.AddModelError("Email", "Emailfield is required!"); modelStateFail = true; } if (string.IsNullOrEmpty(userRegistreViewModel.EmailConfirm)) { this.ModelState.AddModelError("EmailConfirm", "Confirm email field is required!"); modelStateFail = true; } if (!userRegistreViewModel.Email.Equals(userRegistreViewModel.EmailConfirm)) { this.ModelState.AddModelError("EmailConfirm", "Confirm email is different!"); modelStateFail = true; } if (!userRegistreViewModel.Password.Equals(userRegistreViewModel.PasswordConfirm)) { this.ModelState.AddModelError("PasswordConfirm", "Confirm password is different!"); modelStateFail = true; } if (iServiceUser.AlreadyRegistredEmail(userRegistreViewModel.Email)) { this.ModelState.AddModelError("Email", "Email alread registred!"); modelStateFail = true; } if (modelStateFail) { return(View()); } #endregion User user = new Model.Users.User() { Name = userRegistreViewModel.Name, Login = userRegistreViewModel.Login, Email = userRegistreViewModel.Email, Password = userRegistreViewModel.Password, UserType = userRegistreViewModel.UserType }; this.iServiceUser.Insert(user); this.iUnitOfWorkAsync.SaveChanges(); IServiceRole serviceRole = DependencyResolver.Current.GetService <ServiceRole>(); string roleName = ""; if (user.UserType == Model.Enums.UserType.Supplier) { roleName = "Supplier"; IServiceSupplierInfo serviceSupplierInfo = DependencyResolver.Current.GetService <ServiceSupplierInfo>(); SupplierInfo SupplierInfo = new SupplierInfo(); SupplierInfo.User = user; serviceSupplierInfo.Insert(SupplierInfo); } else if (user.UserType == Model.Enums.UserType.Custumer) { roleName = "Custumer"; IServiceCustumerInfo seviceCustumerInfo = DependencyResolver.Current.GetService <ServiceCustumerInfo>(); CustumerInfo custumerInfo = new CustumerInfo(); custumerInfo.User = user; seviceCustumerInfo.Insert(custumerInfo); } serviceRole.AddUserOnRole(roleName, user); this.iUnitOfWorkAsync.SaveChanges(); FormsAuthentication.SetAuthCookie(user.Email, false); ModelState.Remove("Password"); return(RedirectToAction("Edit", "User", new { id = user.ID })); //return View(); }