Ejemplo n.º 1
0
        public void UpdateLastLogin(Guid account_id, DateTime last_login_utc, string platform)
        {
            base.ExecuteMethod("UpdateLastLogin", delegate()
            {
                using (var db = base.CreateSQLContext())
                {
                    if (!string.IsNullOrEmpty(platform) && platform.Length > 250)
                    {
                        platform = platform.Substring(0, 250);
                    }
                    dbAccount found = (from n in db.dbAccounts
                                       where n.account_id == account_id
                                       select n).FirstOrDefault();

                    if (found != null)
                    {
                        found.last_login_utc      = last_login_utc;
                        found.last_login_platform = platform;
                        db.SaveChanges();

                        this.API.Index.Accounts.UpdateLastLogin(account_id, found.ToDomainModel().last_login_utc, platform);
                    }
                }
            });
        }
Ejemplo n.º 2
0
        public bool PasswordResetComplete(Guid account_id, string token, string password)
        {
            return(base.ExecuteFunction("PasswordResetComplete", delegate()
            {
                using (var db = base.CreateSQLContext())
                {
                    dbAccount found = (from a in db.dbAccounts
                                       where a.account_id == account_id &&
                                       a.password_reset_token == token &&
                                       !string.IsNullOrEmpty(token)
                                       select a).FirstOrDefault();

                    if (found != null && !found.deleted_utc.HasValue)
                    {
                        if (found.password_reset_utc.HasValue)
                        {
                            TimeSpan difference = DateTime.UtcNow - found.password_reset_utc.Value;
                            if (difference.TotalHours > 24)
                            {
                                return false;
                            }
                        }
                        found.password_salt = Guid.NewGuid().ToString("N");
                        found.password = GeneratePasswordHash(found.password_salt, password);;
                        found.password_reset_token = string.Empty;
                        found.password_reset_utc = null;
                        db.SaveChanges();

                        this.API.Integration.Email.SendRequestPasswordCompleted(found.email, string.Format("{0} {1}", found.first_name, found.last_name));
                        return true;
                    }
                    return false;
                }
            }));
        }
Ejemplo n.º 3
0
        public void Delete(Guid account_id)
        {
            base.ExecuteMethod("Delete", delegate()
            {
                using (var db = base.CreateSQLContext())
                {
                    dbAccount found = (from a in db.dbAccounts
                                       where a.account_id == account_id
                                       select a).FirstOrDefault();

                    if (found != null)
                    {
                        found.deleted_utc = DateTime.UtcNow;
                        found.InvalidateSync(this.DefaultAgent, "deleted");
                        db.SaveChanges();

                        this.AfterDeletePersisted(db, found);

                        this.Synchronizer.SynchronizeItem(found.account_id, Availability.Retrievable);

                        this.DependencyCoordinator.AccountInvalidated(Dependency.None, found.account_id);
                    }
                }
            });
        }
Ejemplo n.º 4
0
        public Account GetForValidPassword(string email, string password)
        {
            return(base.ExecuteFunction("GetForValidPassword", delegate()
            {
                using (var db = base.CreateSQLContext())
                {
                    if (!string.IsNullOrWhiteSpace(email))
                    {
                        email = email.Trim();
                        dbAccount found = (from a in db.dbAccounts
                                           where a.email == email
                                           select a).FirstOrDefault();

                        if (found != null)
                        {
                            string computedPassword = GeneratePasswordHash(found.password_salt, password);
                            if (computedPassword == found.password)
                            {
                                return found.ToDomainModel();
                            }
                        }
                    }
                }
                return null;
            }));
        }
Ejemplo n.º 5
0
 public static dbAccount ToDbModel(this Account entity, dbAccount destination = null)
 {
     if (entity != null)
     {
         if (destination == null)
         {
             destination = new dbAccount();
         }
         return(am.Mapper.Map <Account, dbAccount>(entity, destination));
     }
     return(null);
 }
Ejemplo n.º 6
0
 public static Account ToDomainModel(this dbAccount entity, Account destination = null)
 {
     if (entity != null)
     {
         if (destination == null)
         {
             destination = new Account();
         }
         return(am.Mapper.Map <dbAccount, Account>(entity, destination));
     }
     return(null);
 }
Ejemplo n.º 7
0
 public Account GetById(Guid account_id)
 {
     return(base.ExecuteFunction("GetById", delegate()
     {
         using (var db = this.CreateSQLContext())
         {
             dbAccount result = (from n in db.dbAccounts
                                 where (n.account_id == account_id)
                                 select n).FirstOrDefault();
             return result.ToDomainModel();
         }
     }));
 }
Ejemplo n.º 8
0
 public Account GetByEmail(string email)
 {
     return(base.ExecuteFunction("GetByEmail", delegate()
     {
         using (var db = this.CreateSQLContext())
         {
             dbAccount result = (from n in db.dbAccounts
                                 where (n.email == email)
                                 select n).FirstOrDefault();
             return result.ToDomainModel();
         }
     }));
 }
Ejemplo n.º 9
0
 public Account GetByApiKey(string api_key)
 {
     return(base.ExecuteFunction("GetByApiKey", delegate()
     {
         using (var db = this.CreateSQLContext())
         {
             dbAccount result = (from n in db.dbAccounts
                                 where (n.api_key == api_key)
                                 select n).FirstOrDefault();
             return result.ToDomainModel();
         }
     }));
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                dba = new dbAccount();
                ddlGender.Items.Clear();
                ddlGender.Items.Add("Select Gender");
                ddlGender.Items.Add("Male");
                ddlGender.Items.Add("Female");
                ddlGender.Items.Add("Decline to Say");
                Load_Quotes();

            }
        }
Ejemplo n.º 11
0
 public Account CreateInitialAccount(Account insertIfEmpty)
 {
     return(base.ExecuteFunction("CreateInitialAccount", delegate()
     {
         dbAccount found = null;
         using (var db = base.CreateSQLContext())
         {
             found = (from a in db.dbAccounts
                      select a).FirstOrDefault();
         }
         if (found == null)
         {
             return Insert(insertIfEmpty);
         }
         return null;
     }));
 }
Ejemplo n.º 12
0
        public void UpdatePushTokenMicrosoft(Guid account_id, string registrationID)
        {
            base.ExecuteMethod("UpdatePushTokenMicrosoft", delegate()
            {
                using (var db = base.CreateSQLContext())
                {
                    dbAccount found = (from a in db.dbAccounts
                                       where a.account_id == account_id
                                       select a).FirstOrDefault();

                    if (found != null && !found.deleted_utc.HasValue)
                    {
                        found.push_microsoft = registrationID;
                        db.SaveChanges();
                    }
                }
            });
        }
Ejemplo n.º 13
0
        public Account Update(Account updateAccount)
        {
            return(base.ExecuteFunction("Update", delegate()
            {
                using (var db = base.CreateSQLContext())
                {
                    this.PreProcess(updateAccount, false);
                    var interception = this.Intercept(updateAccount, false);
                    if (interception.Intercepted)
                    {
                        return interception.ReturnEntity;
                    }

                    updateAccount.updated_utc = DateTime.UtcNow;

                    dbAccount found = (from n in db.dbAccounts
                                       where n.account_id == updateAccount.account_id
                                       select n).FirstOrDefault();

                    if (found != null)
                    {
                        Account previous = found.ToDomainModel();

                        found = updateAccount.ToDbModel(found);
                        found.InvalidateSync(this.DefaultAgent, "updated");
                        db.SaveChanges();

                        this.AfterUpdatePersisted(db, found, previous);

                        this.Synchronizer.SynchronizeItem(found.account_id, Availability.Retrievable);
                        this.AfterUpdateIndexed(db, found);

                        this.DependencyCoordinator.AccountInvalidated(Dependency.None, found.account_id);
                    }

                    return this.GetById(updateAccount.account_id);
                }
            }));
        }
Ejemplo n.º 14
0
        public Account Insert(Account insertAccount)
        {
            return(base.ExecuteFunction("Insert", delegate()
            {
                using (var db = base.CreateSQLContext())
                {
                    this.PreProcess(insertAccount, true);
                    var interception = this.Intercept(insertAccount, true);
                    if (interception.Intercepted)
                    {
                        return interception.ReturnEntity;
                    }

                    if (insertAccount.account_id == Guid.Empty)
                    {
                        insertAccount.account_id = Guid.NewGuid();
                    }
                    insertAccount.created_utc = DateTime.UtcNow;
                    insertAccount.updated_utc = insertAccount.created_utc;

                    dbAccount dbModel = insertAccount.ToDbModel();

                    dbModel.InvalidateSync(this.DefaultAgent, "insert");

                    db.dbAccounts.Add(dbModel);

                    db.SaveChanges();

                    this.AfterInsertPersisted(db, dbModel);

                    this.Synchronizer.SynchronizeItem(dbModel.account_id, Availability.Retrievable);
                    this.AfterInsertIndexed(db, dbModel);

                    this.DependencyCoordinator.AccountInvalidated(Dependency.None, dbModel.account_id);
                }
                return this.GetById(insertAccount.account_id);
            }));
        }
Ejemplo n.º 15
0
        public Account PasswordResetStart(Guid account_id)
        {
            return(base.ExecuteFunction("PasswordResetStart", delegate()
            {
                using (var db = base.CreateSQLContext())
                {
                    dbAccount found = (from a in db.dbAccounts
                                       where a.account_id == account_id
                                       select a).FirstOrDefault();

                    if (found != null && !found.deleted_utc.HasValue)
                    {
                        found.password_reset_token = ShortGuid.NewGuid().ToString();
                        found.password_reset_utc = DateTime.UtcNow;
                        found.InvalidateSync(this.DefaultAgent, "passwordreset");
                        db.SaveChanges();

                        this.API.Integration.Email.SendPasswordResetInitiated(found.email, string.Format("{0} {1}", found.first_name, found.last_name), found.password_reset_token);
                    }
                    return found.ToDomainModel();
                }
            }));
        }
Ejemplo n.º 16
0
 partial void AfterInsertPersisted(StencilContext db, dbAccount account);
Ejemplo n.º 17
0
 partial void AfterUpdatePersisted(StencilContext db, dbAccount account, Account previous);
Ejemplo n.º 18
0
 partial void AfterDeletePersisted(StencilContext db, dbAccount account);
Ejemplo n.º 19
0
 partial void AfterInsertIndexed(StencilContext db, dbAccount account);
Ejemplo n.º 20
0
 partial void AfterUpdateIndexed(StencilContext db, dbAccount account);