Esempio n. 1
0
        public static T Get <T>(this IEnumerable <T> list, WebAppDatabase database, int?id) where T : class, IEntity
        {
            var result = list.Get(id);

            if (result != null)
            {
                result.Database = database;
            }
            var onLoad = result as IOnLoad;

            if (onLoad != null)
            {
                onLoad.OnLoad();
            }
            return(result);
        }
Esempio n. 2
0
        public static WebAppDatabase Login(string username, string password)
        {
            if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
            {
                throw new SystemException("Username Password combination invalid.");
            }

            var database = new WebAppDatabase(username);

            var user = database.Users.FirstOrDefault(x => x.Username == username);

            if (user == null || !user.Active)
            {
                throw new SystemException("Username Password combination invalid.");
            }

            return(database);
        }
Esempio n. 3
0
        public void OnSave(WebAppDatabase database)
        {
            var errors = new StringBuilder();

            errors.AppendError(database.Users.Any(x => x.Username == Username && x.ID != ID), $"The username [{Username}] is already in use.");

            errors.AppendError(string.IsNullOrWhiteSpace(Username), "User requires a username");
            errors.AppendError(string.IsNullOrWhiteSpace(Password), "User requires a password");
            errors.AppendError(Password.IsRegexMatch("^(?=.*[0-9]).{1,}$"), "Requires 1 number.");
            errors.AppendError(Password.IsRegexMatch("^(?=.*[a-z]).{1,}$"), "Requires 1 lower case letter.");
            errors.AppendError(Password.IsRegexMatch("^(?=.*[A-Z]).{1,}$"), "Requires 1 upper case letter.");
            errors.AppendError(Password.IsRegexMatch("[^a-zA-Z0-9 ]"), "Requires 1 special character.");
            errors.AppendError(Password.Length < 8, "Minimun length of 8.");

            errors.AppendError(UserTypeID == 0, "User requires a type");

            errors.ErrorCheck();
        }
Esempio n. 4
0
 public ProductType(WebAppDatabase database) : this()
 {
     Database = database;
 }
Esempio n. 5
0
 public OrderDetail(WebAppDatabase database) : this()
 {
     Database = database;
 }
Esempio n. 6
0
 public User(WebAppDatabase database) : this()
 {
     Database = database;
 }
Esempio n. 7
0
 public static T Get <T>(this IEnumerable <T> set, WebAppDatabase database, Enum id) where T : class, IEntity
 {
     return(set.Get(database, Convert.ToInt32(id)));
 }
Esempio n. 8
0
 public static T Get <T>(this WebAppDatabase db, int?id) where T : class, IEntity
 {
     return(db.Set <T>().Get(db, id));
 }
 public ActivityType(WebAppDatabase database) : this()
 {
     Database = database;
 }
Esempio n. 10
0
 public UserActivity(WebAppDatabase database) : this()
 {
     Database = database;
 }
Esempio n. 11
0
 public LineItem(WebAppDatabase database) : this()
 {
     Database = database;
 }