public IActionResult GetActiveRequests() { int userId = 0, organizationId = 0; string userTypeStr = User.FindFirst(ClaimTypes.Role)?.Value; string userIdVal = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; string userOrgVal = User.FindFirst(ClaimTypes.Country)?.Value; if (string.IsNullOrEmpty(userTypeStr)) { return(BadRequest("Unauthorized user access to api")); } if (string.IsNullOrEmpty(userIdVal)) { return(BadRequest("Unauthorized user access to api")); } if (string.IsNullOrEmpty(userOrgVal)) { return(BadRequest("Unauthorized user access to api")); } userId = Convert.ToInt32(userIdVal); organizationId = Convert.ToInt32(userOrgVal); UserTypes userType = (UserTypes)Convert.ToInt32(userTypeStr); var requests = service.GetDeletionRequests(userType, userId, organizationId); return(Ok(requests)); }
/// <summary>Determines whether the usertype can be updated.</summary> /// <param name="userTypeOfLoggedInUser">The usertype of the user sending the request.</param> /// <exception cref="AccessException">Only admin can change the usertype of a user</exception> private static void CanUserTypeBeUpdated(UserTypes userTypeOfLoggedInUser) { if (userTypeOfLoggedInUser != UserTypes.Admin) { throw new AccessException("Only admin can change usertype!"); } }
/// <summary> /// Creates a new user type /// </summary> /// <param name="name"></param> /// <param name="defaultPermissions"></param> /// <param name="alias"></param> public static UserType MakeNew(string name, string defaultPermissions, string alias) { //ensure that the current alias does not exist //get the id for the new user type var existing = UserTypes.Find(ut => (ut.Alias == alias)); if (existing != null) { throw new Exception("The UserType alias specified already exists"); } var userType = new Umbraco.Core.Models.Membership.UserType { Alias = alias, Name = name, Permissions = defaultPermissions.ToCharArray().Select(x => x.ToString(CultureInfo.InvariantCulture)) }; ApplicationContext.Current.Services.UserService.SaveUserType(userType); var legacy = new UserType(userType); //raise event OnNew(legacy, new EventArgs()); return(legacy); }
private void bindData() { System.Int32 EditId; if (Request.QueryString["id"] == null) { return; } else { EditId = System.Int32.Parse(Request.QueryString["id"].ToString()); Users m_Users = new Users(); m_Users.UserId = EditId; m_Users = m_Users.Get(); txUserName.Text = m_Users.UserName.ToString(); txPassword.Text = m_Users.Password.ToString(); txFullName.Text = m_Users.FullName.ToString(); txAddress.Text = m_Users.Address.ToString(); txEmail.Text = m_Users.Email.ToString(); txMobile.Text = m_Users.Mobile.ToString(); txGenderId.Text = m_Users.GenderId.ToString(); DropDownListHelpers.DDL_Bind(ddlUserStatusId, UserStatuss.Static_GetList(), " ... ", m_Users.UserStatusId.ToString()); DropDownListHelpers.DDL_Bind(ddlUserStatusId, UserTypes.Static_GetList(), " ... ", m_Users.UserTypeId.ToString()); txDefaultActionId.Text = m_Users.DefaultActionId.ToString(); txBirthDay.Text = m_Users.BirthDay.ToString("dd/MM/yyyy"); txCrDateTime.Text = m_Users.CrDateTime.ToString("dd/MM/yyyy"); } }
public override void LoadFromTGSerializedObject(TGSerializedObject _tgs) { base.LoadFromTGSerializedObject(_tgs); UserSource = _tgs.GetString("UserSource"); UserType = (UserTypes)_tgs.GetEnum("UserType", typeof(UserTypes), UserTypes.User); }
/// <summary> /// Creates a new customer. /// </summary> /// <param name="userName">userName.</param> /// <param name="password">The password.</param> /// <param name="userType">Type of the user.</param> /// <param name="customerId">The customer id.</param> /// <param name="errorMessage">The out errorMessage in case of an error.</param> /// <returns> /// the user if created; null if failed to create /// </returns> public Customer CreateCustomer(string userName, string password, UserTypes userType, string customerId, out string errorMessage) { errorMessage = String.Empty; Customer customer = new Customer(); customer.UserName = userName; customer.UserType = userType; customer.Password = password; customer.CustomerId = customerId; try { this._db.Customers.Add(customer); this._db.SaveChanges(); } catch (SystemException ex) { customer = null; errorMessage = this.GetDetaildMessage(ex); Logger.Log(String.Format("Failed to create user:{0}" + "{1}", Environment.NewLine, errorMessage)); } return(customer); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false. /// </returns> public bool Equals(ImportUserTypeOptions other) { return(UserTypes.SequenceEqual(other.UserTypes) && Modules.SequenceEqual(other.Modules) && ImportDependentTypes == other.ImportDependentTypes && UseILCodeWriter == other.UseILCodeWriter); }
public async Task <IActionResult> PutUserTypes(string id, UserTypes userTypes) { if (id != userTypes.UserTypeId) { return(BadRequest()); } _context.Entry(userTypes).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserTypesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { //ensuring that the current implementation is already done... base.OnActionExecuting(filterContext); //Checking whether User is Logged in bool isAuthorized = filterContext.HttpContext.Request.IsAuthenticated; IEnumerable <FilterAttribute> filterAttribute = filterContext.ActionDescriptor.GetFilterAttributes(true) .Where(a => a.GetType() == typeof(UserTypeAccess)); foreach (UserTypeAccess attr in filterAttribute) { UserType = attr.UserType; } var User = filterContext.HttpContext.User; var loggedInUserType = User.ApplicationUserType(); if (loggedInUserType != (decimal)UserType) { //Redirect Redirect(filterContext); } }
public async Task <User> AddUserAsync(AddUserViewModel model, Guid imageId, UserTypes userType) { User user = new User { Address = model.Address, Document = model.Document, Email = model.Username, FirstName = model.FirstName, LastName = model.LastName, ImageId = imageId, PhoneNumber = model.PhoneNumber, City = await _context.Cities.FindAsync(model.CityId), UserName = model.Username, UserType = userType }; IdentityResult result = await _userManager.CreateAsync(user, model.Password); if (result != IdentityResult.Success) { return(null); } User newUser = await GetUserAsync(model.Username); await AddUserToRoleAsync(newUser, user.UserType.ToString()); return(newUser); }
public List <UserTypes> Types() { List <UserTypes> type = new List <UserTypes>(); UserTypes userType; try { SqlConnection connection = ManageDatabaseConnection("Open"); using (SqlCommand sqlCommand = new SqlCommand("readUserType", connection)) { sqlCommand.CommandType = CommandType.StoredProcedure; SqlDataReader reader = sqlCommand.ExecuteReader(); while (reader.Read()) { userType = new UserTypes((int)reader["idUserType"], (string)reader["UserType"]); type.Add(userType); } connection = ManageDatabaseConnection("Close"); return(type); } } catch (SqlException sqlException) { throw sqlException; } }
public IHttpActionResult GetUsers(UserTypes UsertType) { UserLogic userlogic = new UserLogic(); var users = userlogic.GetUsers(UsertType); return(Ok(users)); }
/// <summary> /// Returns all Users of the given UserType that are associated with this FireAlarmSystem. /// </summary> /// <param name="fas">The FireAlarmSystem you want to get the Users of.</param> /// <param name="type">The UserType of Users.</param> /// <returns>Returns all Users of the given UserType that are associated with this FireAlarmSystem.</returns> public static IEnumerable <User> GetUsers(FireAlarmSystem fas, UserTypes type) { List <User> results = new List <User>(); if (type == UserTypes.fireFighter) { foreach (int firebrigade in fas.FireBrigades) { results.AddRange(DatabaseOperations.Users.GetByAuthorizedObject(firebrigade, UserTypes.fireFighter)); } } else { if (type == UserTypes.servicemember) { foreach (int servicegroup in fas.ServiceGroups) { results.AddRange(DatabaseOperations.Users.GetByAuthorizedObject(servicegroup, UserTypes.servicemember)); } } else { if (type == UserTypes.fireSafetyEngineer) { results.AddRange(DatabaseOperations.Users.GetByAuthorizedObject(fas.Id, UserTypes.fireSafetyEngineer)); } } } return(results); }
public int DeleteUserType(UserTypes p_UserType) { MySqlParameter[] parameters = new MySqlParameter[] { new MySqlParameter("p_UserTypeId", p_UserType.UserTypeID) }; return(MySQLDB.MySQLDBHelper.ExecuteNonQuery("DeleteUsertype", CommandType.StoredProcedure, parameters)); }
internal static bool CheckRole(string token, UserTypes typeRequested) { var decodedToken = Decode(token); var tokenRole = decodedToken["role"].ToString(); var userRepository = new UserRepository(); User user = userRepository.GetByUsername(decodedToken["iss"].ToString()); var userRole = user.Type; if (userRole == UserTypes.Administrator.ToString()) { return(true); } if (userRole != tokenRole) { return(false); } if (tokenRole == typeRequested.ToString()) { return(true); } return(false); }
public static string CreateJwt(String username, String email, UserTypes role, long ttlMillis) { if (username == null) { throw new ArgumentNullException(nameof(username)); } if (role.ToString() == null) { throw new ArgumentNullException(nameof(role)); } var currentTime = GetNistTime(); var expiration = currentTime + ttlMillis; var payload = new Dictionary <string, string>() { { "iss", username }, { "sub", email }, { "iat", currentTime.ToString() }, { "exp", expiration.ToString() }, { "role", role.ToString() } }; var secretKey = SecretKey.GetSecretKey(); var key = Encoding.ASCII.GetBytes(secretKey); var token = Jose.JWT.Encode(payload, key, JwsAlgorithm.HS256); return(token); }
IEnumerable <ClientScript> IUIProvider.GetClientScripts(UserTypes type) { return(new List <ClientScript>() { new ClientScript() { Name = "biblref", Content = GetContent("Scripts.biblref.js") }, new ClientScript() { Name = "vm.bibliography", Content = GetContent("Scripts.vm.bibliography.js") }, new ClientScript() { Name = "vm.biblqueries", Content = GetContent("Scripts.vm.biblqueries.js") }, new ClientScript() { Name = "vm.biblquery", Content = GetContent("Scripts.vm.biblquery.js") }, new ClientScript() { Name = "vm.bibliographies", Content = GetContent("Scripts.vm.bibliographies.js") } }); }
public async Task <IActionResult> PutUserTypes([FromRoute] int id, [FromBody] UserTypes userTypes) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userTypes.UserId) { return(BadRequest()); } _context.Entry(userTypes).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserTypesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Users CreateUser(UserViewModel model) { var user = new Users { Id = Guid.NewGuid(), BonusBalance = model.BonusBalance, Email = model.Email, MentorId = model.MentorId, Name = model.Name, Password = model.Password, SecurityLevel = model.SecurityLevel, UserLevel = model.UserLevel, VacationDaysLeft = model.VacationDaysLeft }; foreach (var userType in model.UserTypes) { var userTypeEntity = new UserTypes { Id = Guid.NewGuid(), UserId = user.Id, UserType = userType }; user.UserTypes.Add(userTypeEntity); Db.UserTypes.Add(userTypeEntity); } Db.Users.Add(user); return(user); }
/*public List<ISchemaBase> FindAllByColumn(String ColumnName) * { * this.t * }*/ public override SQLScriptList ToSqlDiff() { var listDiff = new SQLScriptList(); listDiff.Add("USE [" + Name + "]\r\nGO\r\n\r\n", 0, Enums.ScripActionType.UseDatabase); listDiff.AddRange(Assemblies.ToSqlDiff()); listDiff.AddRange(Defaults.ToSqlDiff()); listDiff.AddRange(UserTypes.ToSqlDiff()); listDiff.AddRange(TablesTypes.ToSqlDiff()); listDiff.AddRange(Tables.ToSqlDiff()); listDiff.AddRange(Rules.ToSqlDiff()); listDiff.AddRange(Schemas.ToSqlDiff()); listDiff.AddRange(XmlSchemas.ToSqlDiff()); listDiff.AddRange(Procedures.ToSqlDiff()); listDiff.AddRange(CLRProcedures.ToSqlDiff()); listDiff.AddRange(CLRFunctions.ToSqlDiff()); listDiff.AddRange(FileGroups.ToSqlDiff()); listDiff.AddRange(DDLTriggers.ToSqlDiff()); listDiff.AddRange(Synonyms.ToSqlDiff()); listDiff.AddRange(Views.ToSqlDiff()); listDiff.AddRange(Users.ToSqlDiff()); listDiff.AddRange(Functions.ToSqlDiff()); listDiff.AddRange(Roles.ToSqlDiff()); listDiff.AddRange(PartitionFunctions.ToSqlDiff()); listDiff.AddRange(PartitionSchemes.ToSqlDiff()); listDiff.AddRange(FullText.ToSqlDiff()); return(listDiff); }
public ICollection <ProjectDeletionRequestView> GetDeletionRequests(UserTypes uType, int userId, int orgId) { using (var unitWork = new UnitOfWork(context)) { IEnumerable <EFProjectDeletionRequests> projectRequests = null; var funderProjectIds = unitWork.ProjectFundersRepository.GetProjection(p => p.FunderId == orgId, p => p.ProjectId); var implementerProjectIds = unitWork.ProjectImplementersRepository.GetProjection(p => p.ImplementerId == orgId, p => p.ProjectId); var userOwnedProjects = unitWork.ProjectRepository.GetProjection(p => p.CreatedById == userId, p => p.Id); var projectIds = funderProjectIds.Union(implementerProjectIds).ToList <int>(); List <int> userOwnedProjectIds = new List <int>(); foreach (var pid in userOwnedProjects) { userOwnedProjectIds.Add((int)pid); } projectIds = projectIds.Union(userOwnedProjectIds).ToList <int>(); if (uType == UserTypes.Standard) { foreach (var pid in userOwnedProjects) { userOwnedProjectIds.Add((int)pid); } projectIds = projectIds.Union(userOwnedProjectIds).ToList <int>(); projectRequests = unitWork.ProjectDeletionRepository.GetWithInclude(p => (p.Status == ProjectDeletionStatus.Requested && p.RequestedBy.Id != userId && projectIds.Contains(p.ProjectId)), new string[] { "RequestedBy", "Project", "RequestedBy.Organization" }); } else if (uType == UserTypes.Manager || uType == UserTypes.SuperAdmin) { projectRequests = unitWork.ProjectDeletionRepository.GetWithInclude(d => (d.Status == ProjectDeletionStatus.Approved) || (d.RequestedOn <= DateTime.Now.AddDays(-7) && d.Status == ProjectDeletionStatus.Requested && d.RequestedBy.Id != userId), new string[] { "RequestedBy", "Project", "RequestedBy.Organization" }); //projectRequests = unitWork.ProjectDeletionRepository.GetWithInclude(d => userId != d.RequestedBy.Id, new string[] { "RequestedBy", "Project", "RequestedBy.Organization" }); } return(mapper.Map <List <ProjectDeletionRequestView> >(projectRequests)); } }
public User(string name, string email, string password, UserTypes type) { this.name = name; this.email = email; this.password = password; this.type = type; }
IEnumerable <ClientScript> IUIProvider.GetClientScripts(UserTypes type) { return(new List <ClientScript>() { //TODO: History UI }); }
public static UserType GetUserType(byte[] permissions) { var comparer = new ByteArrayPermissionsComparer(); var result = UserTypes.FirstOrDefault(x => comparer.Compare(x.Permissions, permissions) == 0); return(result ?? UserTypes.ElementAt(3)); }
//convert UserTypes to categories. public List <pb_Category> GetCategories() { var result = new List <pb_Category>(); if (UserTypes == null) { return(result); } List <string> tagList = new List <string>(); string tag, text, str; int index; var temp = UserTypes.Split(new[] { ',' }).ToList(); foreach (var item in temp) { str = item.Trim(); index = str.IndexOf(' '); tag = str.Substring(0, index); text = str.Substring(index, str.Length - index); text = text.Replace("(", ""); text = text.Replace(")", ""); result.Add(new pb_Category { TagName = tag, TextName = text }); } return(result); }
IEnumerable <ClientScript> IUIProvider.GetClientScripts(UserTypes type) { return(new List <ClientScript>() { new ClientScript() { Name = "mymagazines", Content = GetContent("Scripts.mymagazines.js") }, new ClientScript() { Name = "vm.magazinemgr", Content = GetContent("Scripts.vm.magazinemgr.js") }, new ClientScript() { Name = "vm.magazines", Content = GetContent("Scripts.vm.magazines.js") }, new ClientScript() { Name = "vm.subscriptions", Content = GetContent("Scripts.vm.subscriptions.js") }, new ClientScript() { Name = "vm.mysubscriptions", Content = GetContent("Scripts.vm.mysubscriptions.js") }, new ClientScript() { Name = "vm.mymagcustomers", Content = GetContent("Scripts.vm.mymagcustomers.js") } }); }
public Users Update(Guid id, UserViewModel model) { var user = Db.Users.FirstOrDefault(u => u.Id == id); user.Name = model.Name; user.Password = model.Password; user.SecurityLevel = model.SecurityLevel; user.MentorId = model.MentorId; user.UserLevel = model.UserLevel; user.VacationDaysLeft = model.VacationDaysLeft; user.BonusBalance = model.BonusBalance; user.Email = model.Email; var userTypes = Db.UserTypes.Where(x => x.UserId == id); Db.UserTypes.RemoveRange(userTypes); Db.SaveChanges(); foreach (var userType in model.UserTypes) { var userTypeEntity = new UserTypes { Id = Guid.NewGuid(), UserId = id, UserType = userType }; user.UserTypes.Add(userTypeEntity); Db.UserTypes.Add(userTypeEntity); } Db.Users.Update(user); return(user); }
public CallLogDetails(MonthlyCallReportModel monthlyCallReportModel, UserTypes userType) { InitializeComponent(); _monthlyCallReportModel = monthlyCallReportModel; _userType = userType; Lbl_Title.Text = _monthlyCallReportModel.DateFromTo; _viewModel = new CallLogDetailsViewModel(); BindingContext = _viewModel; listView.ItemsSource = _viewModel.CallLogs; listView.ItemSelected += (sender, e) => { if (((ListView)sender).SelectedItem == null) { return; } FifteenCallModel selectedCall = ((ListView)sender).SelectedItem as FifteenCallModel; //DisplayAlert("Item Selected", selectedCall., "Ok"); Navigation.PushAsync(new CallInfo(selectedCall)); ((ListView)sender).SelectedItem = null; }; listView.ItemAppearing += ListView_ItemAppearing; }
public List<UserTypes> Types() { List<UserTypes> type = new List<UserTypes>(); UserTypes userType; try { SqlConnection connection = ManageDatabaseConnection("Open"); using (SqlCommand sqlCommand = new SqlCommand("readUserType", connection)) { sqlCommand.CommandType = CommandType.StoredProcedure; SqlDataReader reader = sqlCommand.ExecuteReader(); while (reader.Read()) { userType = new UserTypes((int)reader["idUserType"], (string)reader["UserType"]); type.Add(userType); } connection = ManageDatabaseConnection("Close"); return type; } } catch (SqlException sqlException) { throw sqlException; } }
private IActionResult register(UserTypes type) { switch (type) { case UserTypes.Buyer: User.Profile = new Buyer(Name, Email, "", "", Username, Password); Buyers.Create((Buyer)User.Profile); return(RedirectToPage("ShopCart")); case UserTypes.Bringer: User.Profile = new Bringer(Name, Email, "", 0, new List <Order>(), Username, Password); Bringers.Create((Bringer)User.Profile); throw new NotImplementedException("We have no bringer pages yet"); return(RedirectToPage("<Bringer Start Page Here>")); // send to start page for bringers case UserTypes.Store: User.Profile = new Store(Name, Email, "", "", 0, Username, Password); Stores.Create((Store)User.Profile); return(RedirectToPage("/Catalog/ProductCatalog")); default: //This should not happen, please throw an exception here return(Page()); } }
//Constractor Without Id. public User(string userName, string password, UserTypes type, bool isVerified) { UserName = userName; Password = password; Type = type; IsVerified = isVerified; }
/// <summary> /// Creates a new customer. /// </summary> /// <param name="userName">userName.</param> /// <param name="password">The password.</param> /// <param name="userType">Type of the user.</param> /// <param name="customerId">The customer id.</param> /// <param name="errorMessage">The out errorMessage in case of an error.</param> /// <returns> /// the user if created; null if failed to create /// </returns> public Customer CreateCustomer(string userName, string password, UserTypes userType, string customerId, out string errorMessage) { errorMessage = String.Empty ; Customer customer = new Customer(); customer.UserName = userName; customer.UserType = userType; customer.Password = password; customer.CustomerId = customerId; try { this._db.Customers.Add(customer); this._db.SaveChanges(); } catch (SystemException ex) { customer = null; errorMessage = this.GetDetaildMessage(ex); Logger.Log(String.Format("Failed to create user:{0}" +"{1}", Environment.NewLine, errorMessage)); } return customer; }
internal UsersUtility(string originalFileNameWPath, UserTypes userType, string id, string name, string language, string outputFolder, bool addRemoveFlag) : base(string.Empty, language, null, outputFolder) { this._originalFileNameWPath = originalFileNameWPath; this._userType = userType; this._id = id; this._name = name; this._addRemoveFlag = addRemoveFlag; }
public PermissionItem(Guid permissionItemGuid, int permissionItemValue, Guid createUserGuid, UserTypes createUserType, Logics isFreeAwayCreator) { this.permissionKey = GuidHelper.NewGuid(); this.permissionItemGuid = permissionItemGuid; this.permissionItemValue = permissionItemValue; this.createUserGuid = createUserGuid; this.createUserType = createUserType; this.isFreeAwayCreator = isFreeAwayCreator; }
// CONSTRUCTOR public PurpleNetworkUser() { UserGUID = new Guid (); UserID = -1; UserType = UserTypes.User; UserAuthenticated = false; UserConnectedTime = DateTime.Now; UserName = String.Empty; UserPassword = String.Empty; UserToken = String.Empty; }
public int GetUsertypeDiscount(UserTypes usertype) { switch (usertype) { case UserTypes.Company: return (int)UserTypes.Company; case UserTypes.Normal: return (int)UserTypes.Normal; default: throw new KeyNotFoundException(ErrorMessage(typeof(UserTypes).Name)); } }
public PurpleNetworkUser(NetworkPlayer player) { UserReference = player; UserGUID = new Guid (); UserID = -1; UserType = UserTypes.User; UserAuthenticated = false; UserConnectedTime = DateTime.Now; UserName = String.Empty; UserPassword = String.Empty; UserToken = String.Empty; UserTokenCreated = DateTime.MinValue; }
/// <summary> /// Creates a new customer. /// </summary> /// <param name="userName">userName.</param> /// <param name="password">The password.</param> /// <param name="userType">Type of the user.</param> /// <param name="customerId">The customer id.</param> /// <param name="errorMessage">The out errorMessage in case of an error.</param> /// <returns> /// the user if created; null if failed to create /// </returns> public Customer CreateCustomer(string userName, string password, UserTypes userType, string customerId, out string errorMessage) { errorMessage = String.Empty ; Customer customer = new Customer(); customer.UserName = userName; customer.UserType = userType; customer.Password = password; customer.CustomerId = customerId; try { this._db.Customers.Add(customer); this._db.SaveChanges(); } catch (SystemException ex) { customer = null; //if we can get more specific details, do it... if (ex is DbEntityValidationException) { List<DbEntityValidationResult> validationErrors = this._db.GetValidationErrors().ToList(); foreach (DbEntityValidationResult currResult in validationErrors) { //get the error message List<DbValidationError> errors= currResult.ValidationErrors.ToList(); List<String> errorString = errors.Select(error => error.ErrorMessage).ToList(); errorMessage += String.Join(Environment.NewLine, errorString); } //errorMessage = String.Join(Environment.NewLine,this._db.GetValidationErrors().ToList()); } else { errorMessage = ex.Message; } Logger.Log(String.Format("Failed to create user:{0}" +"{1}", Environment.NewLine, errorMessage)); } return customer; }
public string GetUserNotificationsAsXml(string username, int count, UserTypes userType) { List<UserNotification> list = null; if (userType == UserTypes.Student) list = GetAllStudentNotifications(username); else if (userType == UserTypes.Teacher) list = GetAllTeacherNotifications(username); if (list != null) { if (count < list.Count) list = list.GetRange(list.Count - count, count); return GetXmlFromNotifications(list); } return String.Empty; }
internal SubscriptionUtility(string id, string userId, UserTypes userType, List<bool> isSOAPMailIds, List<string> notificationMailIds, List<bool> isSOAPHTTPs, List<string> notificationHTTPs, string subscriberAssignedId, DateTime startDate, DateTime endDate, string EventSelector, Dictionary<string, string> dictCategories,string MFDId, string agencyId, Header header, string outputFolder) : base(agencyId, string.Empty, header, outputFolder) { this._id = id; this._userId = userId; this._userType = userType; this._isSOAPMailIds = isSOAPMailIds; this._notificationMailIds = notificationMailIds; this._isSOAPHTTPs = isSOAPHTTPs; this._notificationHTTPs = notificationHTTPs; this._subscriberAssignedId = subscriberAssignedId; this._startDate = startDate; this._endDate = endDate; this._eventSelector = EventSelector; this._dictCategories = dictCategories; this._mfdId = MFDId; }
public int GetFee(UserTypes usertype, ItemTypes itemtype, int itemprice, DateTime itemenddate, IGetDiscountValue iGetDiscountValue) { if (itemprice <= 0) { throw new Exception("Itemprice can not be negetive"); } try { var itemTypeDiscount = iGetDiscountValue.GetItemFee(itemtype); var userdiscount = iGetDiscountValue.GetUsertypeDiscount(usertype); var enddatediscount = iGetDiscountValue.GetEndDateDiscount(itemtype, itemenddate); return itemprice + itemTypeDiscount - (userdiscount + enddatediscount); } catch { throw new Exception("Invalid input"); } }
public User GetUser(string username, UserTypes type) { switch (type) { case UserTypes.Sysop: return UsersCollection.Collection.FindOneByIdAs<Sysop>(username); case UserTypes.Faculty: return UsersCollection.Collection.FindOneByIdAs<Faculty>(username); case UserTypes.Teacher: return UsersCollection.Collection.FindOneByIdAs<Teacher>(username); case UserTypes.Student: return UsersCollection.Collection.FindOneByIdAs<Student>(username); default: return null; } }
/// <summary> /// Matches the GUI to specified user type. /// </summary> /// <param name="userType">Type of the user.</param> private void MatchGuiToUserType(UserTypes? userType) { //if user is not logged in, we will treat him as lowest level of permissions var affectiveUserType = this.CurrentUserType ?? UserTypes.User; bool showEditControls = false; switch (affectiveUserType) { case UserTypes.Admininstrator: case UserTypes.Editor: showEditControls = true; this.rdbShowEditorControls.Checked = true; break; case UserTypes.User: showEditControls = false; break; default: throw new ArgumentOutOfRangeException("Got an unknown user type"); } if (showEditControls) { this.rdbShowEditorControls.Show(); this.rdbShowUserControls.Show(); } else { this.rdbShowEditorControls.Hide(); this.rdbShowUserControls.Hide(); } //Set column visibility and editibility this.SetColumnStateByUserType(affectiveUserType); }
/// <summary> /// Sets the column visibility andEditability state by user type. /// </summary> /// <param name="userType">Type of the user.</param> private void SetColumnStateByUserType(UserTypes userType) { //if products are bound, setting column visibility DataTable dtProducts = this.GetProductsTableFromDataSource(); if (dtProducts != null) { foreach (DataGridViewColumn col in this.gvProducts.Columns) { DataColumn dataCol = dtProducts.Columns[col.Name]; //we need to check because we have some unbound columns if (dataCol != null) { if (DataTableConstans.ColAvailabilityForUserType.ContainsKey(dataCol.ColumnName)) { /*Visibility*/ bool visibilityState = DataTableConstans.ColAvailabilityForUserType[dataCol.ColumnName].Contains(userType); col.Visible = visibilityState; /*Editabillity*/ bool setEditable = DataTableConstans.ColEditebilityForUserType[dataCol.ColumnName].Contains(userType); col.ReadOnly = !setEditable; } } } } }
public static string Type2Text(UserTypes value) { switch (value) { case UserTypes.System: return Languages.Libs.GetString("system"); default : return Languages.Libs.GetString("investor"); } }
public void UpdateUserType(UserTypes userType, string username) { var user = UsersCollection.Collection.FindOneByIdAs<User>(username); if (user != null) user.UserType = userType; SaveUser(user); }
IEnumerable<ClientScript> IUIProvider.GetClientScripts(UserTypes type) { return new List<ClientScript>() { new ClientScript(){ Name = "bibllist", Content = GetContent("Scripts.bibllist.js") }, new ClientScript(){ Name = "vm.bibllistqueries", Content = GetContent("Scripts.vm.bibllistqueries.js") }, new ClientScript(){ Name = "vm.bibllistquery", Content = GetContent("Scripts.vm.bibllistquery.js") } }; }
IEnumerable<ClientScript> IUIProvider.GetClientScripts(UserTypes type) { return new List<ClientScript>() { new ClientScript(){ Name = "refanalysis", Content = GetContent("Scripts.refanalysis.js") }, new ClientScript(){ Name = "vm.analysisqueries", Content = GetContent("Scripts.vm.analysisqueries.js") }, new ClientScript(){ Name = "vm.analysisquery", Content = GetContent("Scripts.vm.analysisquery.js") } }; }
public string GetClientTemplates(UserTypes type) { //if (type == UserTypes.Admin) // return GetContent("Templates.AdminUI.html"); return string.Empty; }
IEnumerable<ClientScript> IUIProvider.GetClientScripts(UserTypes type) { var scripts = new List<ClientScript>(); if (type == UserTypes.Librarian || type == UserTypes.Customer) { scripts.Add(new ClientScript() { Name = "askthelib", Content = GetContent("Scripts.askthelib.js") }); scripts.Add(new ClientScript() { Name = "vm.inqueries", Content = GetContent("Scripts.vm.inqueries.js") }); scripts.Add(new ClientScript() { Name = "vm.inquery", Content = GetContent("Scripts.vm.inquery.js") }); }; return scripts; }
public bool InsertUser(string username, string password, string email, UserTypes userType) { var bl = new UsersBL(); return bl.InsertUser(username, password, email, userType); }
/// <summary> /// 获取用户列表 /// </summary> /// <param name="userType">用户类型</param> /// <param name="userStatus">用户状态</param> /// <returns></returns> public static List<BusinessUser> GetList(UserTypes userType,UserStatuses? userStatus) { string whereClause = string.Format(" UserType={0} ", (int)userType); if (userStatus.HasValue) { whereClause += string.Format(" AND UserStatus={0} ",(int)userStatus.Value); } return GetList(whereClause); }
/// <summary> /// 获取用户列表 /// </summary> /// <param name="userType">用户类型</param> /// <returns></returns> public static List<BusinessUser> GetList(UserTypes userType) { return GetList(userType,null); }
/// <summary> /// Gets the customers filtered by user name and password. /// If you do not want to filter by those items use null or <see cref="String.Empty"/> /// </summary> /// <param name="userName">the username (null or <see cref="String.Empty"/> for not filtering by username).</param> /// <param name="password">The password (null or <see cref="String.Empty"/> for not filtering by password).</param> /// <param name="userType">Type of the user (null for not filtering by user type).</param> /// <returns> /// The <see cref="ShopSmart.Dal.User[]"/> object that represents the users /// That qualify filter. /// </returns> public List<Customer> GetCustomers(string userName, string password, UserTypes? userType) { List<Customer> users = this._db.Customers.ToList(); /* Filter by username */ if (!String.IsNullOrWhiteSpace(userName)) { users = users.Where(customer => customer.UserName == userName).ToList(); } /* Filter by password */ if (!String.IsNullOrWhiteSpace(password)) { users = users.Where(customer => customer.Password == password).ToList(); } /* Filter by usertype */ if (userType.HasValue) { users = users.Where(customer => customer.UserType == userType.Value).ToList(); } return users; }
public bool InsertUser(string username, string password, string email, UserTypes userType) { return dal.InsertUser(new User { Id = username, Password = password, Email = email, UserType = userType }); }
public bool ValidateUser(string username, string password, UserTypes type) { var usernameExists = Query.EQ("_id", username); var passwordExists = Query.EQ(Users.Password.Key, password); var userIsValid = Query.And(usernameExists, passwordExists); try { switch (type) { case UserTypes.Sysop: return UsersCollection.Collection.FindAs<Sysop>(userIsValid).Any(); case UserTypes.Faculty: return UsersCollection.Collection.FindAs<Faculty>(userIsValid).Any(); case UserTypes.Teacher: return UsersCollection.Collection.FindAs<Teacher>(userIsValid).Any(); case UserTypes.Student: return UsersCollection.Collection.FindAs<Student>(userIsValid).Any(); } } catch (Exception ex) { ExceptionLogger.Log(ex); } return false; }
IEnumerable<ClientScript> IUIProvider.GetClientScripts(UserTypes type) { return new List<ClientScript>() { new ClientScript(){ Name="mymagazines", Content = GetContent("Scripts.mymagazines.js") }, new ClientScript(){ Name="vm.magazinemgr", Content = GetContent("Scripts.vm.magazinemgr.js") }, new ClientScript(){ Name="vm.magazines", Content = GetContent("Scripts.vm.magazines.js") }, new ClientScript(){ Name="vm.subscriptions", Content = GetContent("Scripts.vm.subscriptions.js") }, new ClientScript(){ Name="vm.mysubscriptions", Content = GetContent("Scripts.vm.mysubscriptions.js") }, new ClientScript(){ Name="vm.mymagcustomers", Content = GetContent("Scripts.vm.mymagcustomers.js") } }; }
IEnumerable<ClientScript> IUIProvider.GetClientScripts(UserTypes type) { return new List<ClientScript>() { new ClientScript(){ Name = "finance", Content = GetContent("Scripts.finance.js") }, new ClientScript(){ Name = "vm.payments", Content = GetContent("Scripts.vm.payments.js") } }; }
public bool ValidateUser(string username, string password, UserTypes type) { return dal.ValidateUser(username, password, type); }
IEnumerable<ClientScript> IUIProvider.GetClientScripts(UserTypes type) { return new List<ClientScript>() { //TODO: History UI }; }