/// <summary> /// Create a new PendingUser object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="creationDate">Initial value of the CreationDate property.</param> /// <param name="companyId">Initial value of the CompanyId property.</param> /// <param name="email">Initial value of the Email property.</param> /// <param name="roles">Initial value of the Roles property.</param> /// <param name="languageId">Initial value of the LanguageId property.</param> public static PendingUser CreatePendingUser(global::System.Int32 id, global::System.DateTime creationDate, global::System.Int32 companyId, global::System.String email, global::System.Int32 roles, global::System.Int32 languageId) { PendingUser pendingUser = new PendingUser(); pendingUser.Id = id; pendingUser.CreationDate = creationDate; pendingUser.CompanyId = companyId; pendingUser.Email = email; pendingUser.Roles = roles; pendingUser.LanguageId = languageId; return pendingUser; }
/// <summary> /// Deprecated Method for adding a new object to the PendingUsers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPendingUsers(PendingUser pendingUser) { base.AddObject("PendingUsers", pendingUser); }
public ActionResult EditPending(PendingUser user, string[] roleNames) { if (Authorized(RoleType.SystemManager)) { if (ModelState.IsValid) { PendingUser userFromDatabase; using (PendingUsersRepository pendingUserRep = new PendingUsersRepository()) { userFromDatabase = pendingUserRep.GetEntity(user.Id); if (userFromDatabase != null) { if (userFromDatabase.CompanyId != CurrentUser.CompanyId) return Error(Loc.Dic.error_no_permission); RoleType combinedRoles = RoleType.None; List<RoleType> forbiddenRoles = GetForbiddenRoles(); foreach (string roleName in roleNames) { RoleType role; if (Enum.TryParse(roleName, out role) && !forbiddenRoles.Contains(role)) { combinedRoles = Roles.CombineRoles(combinedRoles, role); } else { return Error(Loc.Dic.error_invalid_form); } } userFromDatabase.Email = user.Email; userFromDatabase.Roles = (int)combinedRoles; userFromDatabase.OrdersApproverId = user.OrdersApproverId.HasValue && user.OrdersApproverId.Value == -1 ? null : user.OrdersApproverId; pendingUserRep.Update(userFromDatabase); return RedirectToAction("Index"); } else { return Error(Loc.Dic.error_user_not_found); } } } else { return Error(ModelState); } } else { return Error(Loc.Dic.error_no_permission); } }