Exemplo n.º 1
0
 public Administrator(string username, string password, UserEnum userType)
 {
     this.username = username;
     this.password = password;
     this.userType = userType;
     this.id       = Guid.NewGuid();
 }
Exemplo n.º 2
0
 public void SeeActivity(IUser user, string password, UserEnum type)
 {
     if (string.Equals(user.Password, password))
     {
         //Utilities.ShowActivity(user);
     }
 }
Exemplo n.º 3
0
 private void CreateAccount_Click(object sender, EventArgs e)
 {
     this.Name     = this.textName.Text;
     this.Password = this.textPassword.Text;
     Role          = UserEnum.User;
     try
     {
         passwordAndLogin.Add(Name, Password);
         User user = new User()
         {
             Name     = this.textName.Text,
             Password = this.textPassword.Text,
             Role     = UserEnum.User
         };
         users.Add(user);
         string serializeString = JsonConvert.SerializeObject(users, Formatting.Indented,
                                                              new JsonSerializerSettings
         {
             ReferenceLoopHandling = ReferenceLoopHandling.Ignore
         });
         File.WriteAllText(UserDataPath, serializeString);
         this.DialogResult = DialogResult.OK;
     }
     catch (ArgumentException)
     {
         MessageBox.Show(@"User name is exist");
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
Exemplo n.º 4
0
 public Administrator(string username, string password, UserEnum userType)
 {
     Username = username;
     //Password = password;
     UserType = userType;
     ID       = Guid.NewGuid();
 }
 internal ShoppingCart GetShoppingCart(UserEnum userId)
 {
     return(userId switch
     {
         UserEnum.Quantrell => new ShoppingCart()
         {
             UserId = UserEnum.Quantrell,
             Items = new List <CartItem>()
             {
                 new CartItem()
                 {
                     ItemName = "Cherry MX Red Switches",
                     Quantity = 104
                 }
             }
         },
         UserEnum.Greta => new ShoppingCart()
         {
             UserId = UserEnum.Greta,
             Items = new List <CartItem>()
             {
                 new CartItem()
                 {
                     ItemName = "Paintballs",
                     Quantity = 400
                 }
             }
         },
         _ => throw new KeyNotFoundException("Could not find user in database"),
     });
Exemplo n.º 6
0
 public UserModel(string username, SecureString password, string firstName, string lastName, UserEnum userType)
 {
     Username     = username;
     PasswordSalt = SecurePasswordUtility.CreateSalt();
     PasswordHash = new SecurePasswordUtility(password, PasswordSalt).ComputeSaltedHash();
     FirstName    = firstName;
     LastName     = lastName;
     UserType     = userType;
     ID           = Guid.NewGuid();
 }
Exemplo n.º 7
0
        public async Task <UpdateResult> UpdateUser(string id, UserEnum role)
        {
            var filter = Builders <User> .Filter.Eq(s => s.Id, id);

            var update = Builders <User> .Update
                         .Set(s => s.Role, role);

            return(await _userContext.UsersCollection.
                   UpdateOneAsync(filter, update));
        }
Exemplo n.º 8
0
 public Customer(string username, string password, string firstName, string lastName, UserEnum userType)
 {
     Username       = username;
     PasswordSalt   = Utilities.CreateSalt();
     SecurePassword = new SecurePassword(password, PasswordSalt);
     PasswordHash   = SecurePassword.ComputeSaltedHash();
     FirstName      = firstName;
     LastName       = lastName;
     UserType       = userType;
     ID             = Guid.NewGuid();
 }
Exemplo n.º 9
0
        public CreateAccount(string firstName, string lastName, string userName, string password, string email, UserEnum userType)
        {
            this.firstName = firstName;
            this.lastName = lastName;
            this.userName = userName;
            this.encriptPass = _PassEncription.Encript(password);
            this.email = email;
            this.userType = userType;

            //insert code to make new account here
        }
Exemplo n.º 10
0
        private UserEnum DefineEnum(String namespace_, String name, List <String> modifiers)
        {
            TypeAttributes attr = 0;

            foreach (String s in modifiers)
            {
                attr |= (TypeAttributes)Enum.Parse(typeof(TypeAttributes), s, true);
            }
            UserEnum tb = new UserEnum(name, namespace_, attr);

            return(tb);
        }
        public IYearSheetRepository GetRepository(UserEnum user)
        {
            switch (user)
            {
            case UserEnum.Green:
                return(new YearSheetRepository(_sheetDetails.GreenSheetId, _sheetDetails, _sheetApi));

            case UserEnum.Red:
                return(new YearSheetRepository(_sheetDetails.RedSheetId, _sheetDetails, _sheetApi));

            default:
                throw new ArgumentException("Unknown User Enum");
            }
        }
Exemplo n.º 12
0
        private void Login_Click(object sender, EventArgs e)
        {
            this.Name = this.textName.Text;
            // this.Password = this.textPassword.Text;
            string pass;

            if (passwordAndLogin.TryGetValue(this.textName.Text, out pass))
            {
                if (pass == this.textPassword.Text)
                {
                    this.Role = users.FirstOrDefault(user => user.Name == this.textName.Text && user.Password == this.textPassword.Text
                                                     ).Role;
                    this.DialogResult = DialogResult.OK;
                }
            }
        }
Exemplo n.º 13
0
        public decimal LoadPersonalCurrentBalance(UserEnum user)
        {
            string balanceRange = null;

            switch (user)
            {
            case UserEnum.Green:
                balanceRange = _sheetDetails.GreenCurrentBalance;
                break;

            case UserEnum.Red:
                balanceRange = _sheetDetails.RedCurrentBalance;
                break;

            default: break;
            }
            return(decimal.Parse(LoadSingle(balanceRange)));
        }
Exemplo n.º 14
0
        public void GetUser()
        {
            LogInPage formLogIn = new LogInPage();

            formLogIn.ShowDialog();
            if (formLogIn.DialogResult == DialogResult.OK)
            {
                userName = formLogIn.Name;
                Role     = formLogIn.Role;
            }
            //else
            //{
            //    InitializeComponent();
            //    Vizible();
            //    Initializer();
            //    this.Close();
            //}
        }
Exemplo n.º 15
0
 /// <summary>
 /// Partially walk the tree and define all classes and interfaces encountered in the assembly.
 /// </summary>
 /// <param name="node">The tree to walk</param>
 public void WalkTypes(TreeNode node)
 {
     // manually traverse the AST so we can first define all classes before references to them are made
     foreach (TreeNode n in node.Children)
     {
         if (n.Type == VnvdTreeWalker.NAMESPACE)
         {
             foreach (TreeNode n2 in n.Children)
             {
                 if (n2.Entry != null && n2.EntryType == EntryType.Class)
                 {
                     UserType t = (UserType)n2.Entry.ReflectionObject;
                     n2.Entry.ReflectionObject = DefineClass(t.FullName, t.Attributes);
                     ((UserType)t.MakeArrayType()).Entry.ReflectionObject =
                         ((TypeBuilder)n2.Entry.ReflectionObject).MakeArrayType();
                     usertypes.Add(t);
                     types.Add(n2);
                 }
                 else if (n2.Entry != null && n2.EntryType == EntryType.Interface)
                 {
                     UserType t = (UserType)n2.Entry.ReflectionObject;
                     n2.Entry.ReflectionObject = DefineInterface(t.FullName, t.Attributes);
                     ((UserType)t.MakeArrayType()).Entry.ReflectionObject =
                         ((TypeBuilder)n2.Entry.ReflectionObject).MakeArrayType();
                     usertypes.Insert(0, t);
                     types.Insert(0, n2);
                 }
                 else if (n2.Entry != null && n2.EntryType == EntryType.Enum)
                 {
                     UserEnum t = (UserEnum)n2.Entry.ReflectionObject;
                     n2.Entry.ReflectionObject = DefineEnum(t.FullName, t.Attributes);
                     ((UserType)t.MakeArrayType()).Entry.ReflectionObject =
                         ((TypeBuilder)n2.Entry.ReflectionObject).MakeArrayType();
                     usertypes.Insert(0, t);
                     types.Insert(0, n2);
                 }
             }
         }
     }
 }
Exemplo n.º 16
0
        public void ChooseMenu()
        {
            UserEnum choose = (UserEnum)int.Parse(Console.ReadLine());

            while (choose == UserEnum.None)
            {
                Console.WriteLine("Envalid Input Try Again!");
                choose = (UserEnum)int.Parse(Console.ReadLine());
            }

            switch (choose)
            {
            case UserEnum.Register:
                var regist = new RegisterAthenticate();
                regist.Registaraion();
                Clear();
                AskUser();
                break;

            case UserEnum.Authenticate:
                //Authenticate autho = new Authenticate();
                //autho.Authorize();
                RegisterAthenticate valid = new RegisterAthenticate();
                valid.AskAuthenticate();
                Clear();
                AskUser();
                break;

            case UserEnum.Exit:
                ExitSystem();
                break;

            default:
                Console.Clear();
                Console.WriteLine("Wrong Input Try again");
                AskUser();
                break;
            }
        }
Exemplo n.º 17
0
 public async Task Put([FromBody] string id, UserEnum role)
 {
     await _userService.UpdateUser(id, role);
 }
Exemplo n.º 18
0
 public User(string name, UserEnum role)
 {
     this.Name = name;
     this.Role = role;
 }
Exemplo n.º 19
0
        public IList <RangeUpdateModel> PrepUpdatePersonalStartingBalance(decimal value, UserEnum user)
        {
            string balanceRange = null;

            switch (user)
            {
            case UserEnum.Green:
                balanceRange = _sheetDetails.GreenStartingBalance;
                break;

            case UserEnum.Red:
                balanceRange = _sheetDetails.RedStartingBalance;
                break;

            default: break;
            }

            return(PrepSingleCellUpdate(value, balanceRange));
        }
Exemplo n.º 20
0
 public Patient(string name, UserEnum role) : base(name, role)
 {
 }
Exemplo n.º 21
0
        private WrappedResponse <CategoriesPersonal> SaveCategoriesToUserYearSheet(CategoriesPersonal categories, UserEnum user, DateTime effectiveDate)
        {
            var repo    = _repositoryFactory.GetRepository(user);
            var updates = repo.PrepExpenseUpdate(categories.Expense, effectiveDate);

            updates.AddRange(repo.PrepIncomeUpdate(categories.Income, effectiveDate));
            var updateResponse = repo.UpdateRange(updates);

            if (!updateResponse.Success)
            {
                return((WrappedResponse <CategoriesPersonal>)updateResponse);
            }
            var projections = repo.LoadProjections();

            return(new WrappedResponse <CategoriesPersonal> {
                Success = true, Data = projections
            });
        }
Exemplo n.º 22
0
        private IList <RangeUpdateModel> PrepCategoryProjectionsUpdate(Categories categories, UserEnum user)
        {
            var personalCategories = user == UserEnum.Green ?
                                     categories.Green :
                                     categories.Red;

            // build expense projections
            var updates = _repo.PrepExpenseCategoryProjectionUpdate(personalCategories.Expense, user);

            // build income projections
            updates.AddRange(_repo.PrepIncomeCategoryProjectionUpdate(personalCategories.Income, user));

            return(updates);
        }
        public IList <RangeUpdateModel> PrepIncomeCategoryProjectionUpdate(CategoriesIncome income, UserEnum user)
        {
            var update = new RangeUpdateModel();

            update.Range = user == UserEnum.Green ?
                           _sheetDetails.GreenIncomeProjectionRange :
                           _sheetDetails.RedIncomeProjectionRange;

            update.Dimension = DimensionEnums.Columns;

            var catchAllValue = income.Payment + income.Gifts + income.Refund + income.Other;

            update.Values = new List <IList <object> > {
                new List <object> {
                    0,
                    income.Paycheck,
                },
            };

            return(new List <RangeUpdateModel> {
                update
            });
        }
        private CategoriesPersonal LoadPersonalCategories(UserEnum user)
        {
            string expenseRange = null;
            string incomeRange  = null;

            switch (user)
            {
            case UserEnum.Green:
                expenseRange = _sheetDetails.GreenExpenseCategoriesRange;
                incomeRange  = _sheetDetails.GreenIncomeCategoriesRange;
                break;

            case UserEnum.Red:
                expenseRange = _sheetDetails.RedExpenseCategoriesRange;
                incomeRange  = _sheetDetails.RedIncomeCategoriesRange;
                break;

            default: break;
            }

            // load expense categories
            var rawExpense = LoadRange(expenseRange);
            var expense    = new CategoriesExpense();

            if (rawExpense != null && rawExpense.Count > 0)
            {
                expense.Total = decimal
                                .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Total][0].ToString());
                expense.DailyFood = decimal
                                    .Parse(rawExpense[(int)CategoriesExpenseRowEnum.DailyFood][0].ToString());
                expense.Gifts = decimal
                                .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Gifts][0].ToString());
                expense.Medical = decimal
                                  .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Medical][0].ToString());
                expense.Health = decimal
                                 .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Health][0].ToString());
                expense.Necessities = decimal
                                      .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Necessities][0].ToString());
                expense.Transportation = decimal
                                         .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Transportation][0].ToString());
                expense.Personal = decimal
                                   .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Personal][0].ToString());
                expense.Fun = decimal
                              .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Fun][0].ToString());
                expense.Utilities = decimal
                                    .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Utilities][0].ToString());
                expense.Travel = decimal
                                 .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Travel][0].ToString());
                expense.Debt = decimal
                               .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Debt][0].ToString());
                expense.Electronics = decimal
                                      .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Electronics][0].ToString());
                expense.Goals = decimal
                                .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Goals][0].ToString());
                expense.Rent = decimal
                               .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Rent][0].ToString());
                expense.Car = decimal
                              .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Car][0].ToString());
                expense.Restaurants = decimal
                                      .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Restaurants][0].ToString());
                expense.Appartment = decimal
                                     .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Appartment][0].ToString());
                expense.Investment = decimal
                                     .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Investment][0].ToString());
                expense.Other = decimal
                                .Parse(rawExpense[(int)CategoriesExpenseRowEnum.Other][0].ToString());
            }

            // load income categories
            var rawIncome = LoadRange(incomeRange);
            var income    = new CategoriesIncome();

            if (rawIncome != null && rawIncome.Count > 0)
            {
                income.Total = decimal
                               .Parse(rawIncome[(int)CategoriesIncomeRowEnum.Total][0].ToString());
                income.Savings = decimal
                                 .Parse(rawIncome[(int)CategoriesIncomeRowEnum.Savings][0].ToString());
                income.Paycheck = decimal
                                  .Parse(rawIncome[(int)CategoriesIncomeRowEnum.Paycheck][0].ToString());
                income.Bonus = decimal
                               .Parse(rawIncome[(int)CategoriesIncomeRowEnum.Bonus][0].ToString());
                income.Personal = decimal
                                  .Parse(rawIncome[(int)CategoriesIncomeRowEnum.Personal][0].ToString());
                income.Gifts = decimal
                               .Parse(rawIncome[(int)CategoriesIncomeRowEnum.Gifts][0].ToString());
                income.Refund = decimal
                                .Parse(rawIncome[(int)CategoriesIncomeRowEnum.Refund][0].ToString());
                income.Payment = decimal
                                 .Parse(rawIncome[(int)CategoriesIncomeRowEnum.Payment][0].ToString());
                income.Other = decimal
                               .Parse(rawIncome[(int)CategoriesIncomeRowEnum.Other][0].ToString());
            }


            return(new CategoriesPersonal
            {
                Expense = expense,
                RawExpense = rawExpense,
                Income = income,
                RawIncome = rawIncome
            });
        }
Exemplo n.º 25
0
 public void SeeActivity(IUser user, string password, UserEnum type)
 {
     //Utilities.ShowActivity(user);
 }
        public IList <RangeUpdateModel> PrepExpenseCategoryProjectionUpdate(CategoriesExpense expenses, UserEnum user)
        {
            var expenseUpdateModel = new RangeUpdateModel();

            expenseUpdateModel.Range = user == UserEnum.Green ?
                                       _sheetDetails.GreenExpenseProjectionRange :
                                       _sheetDetails.RedExpenseProjectionRange;

            expenseUpdateModel.Dimension = DimensionEnums.Columns;

            // TODO: use order-safe enum
            expenseUpdateModel.Values = new List <IList <object> > {
                new List <object> {
                    expenses.DailyFood,
                    expenses.Gifts,
                    expenses.Medical,
                    expenses.Health,
                    expenses.Necessities,
                    expenses.Transportation,
                    expenses.Personal,
                    expenses.Fun,
                    expenses.Utilities,
                    expenses.Travel,
                    expenses.Debt,
                    expenses.Electronics,
                    expenses.Goals,
                    expenses.Rent,
                    expenses.Car,
                    expenses.Restaurants,
                    expenses.Appartment,
                    expenses.Investment,
                    expenses.Other
                },
            };
            return(new List <RangeUpdateModel> {
                expenseUpdateModel
            });
        }