Exemplo n.º 1
0
        public IPeople GetByLoginDetails(string emailId, string password)
        {
            IPeople user = new MyDiary.Domain.Domains.People();

            user.UserRoles = new List <IRole>()
            {
                new Role()
            };
            user.UserImages = new List <IImage>()
            {
                new Image()
            };

            SqlConnection conn = SQLDbConnection.GetNewSqlConnectionObject();

            conn.Open();
            SqlCommand cmd = SQLDbConnection.GetNewSqlCommandObject(conn, Constants.StoredProcedures.People.USERLOGIN_SELECT);

            cmd.Parameters.AddWithValue(Constants.StoredProcedures.People.Parameters.EmailId, emailId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.People.Parameters.Password, password);
            DataTable dtUser = SQLDbConnection.FillDataSetFromDataAdapter(SQLDbConnection.GetNewSqlDataAdapterObject(cmd));

            if (dtUser != null && dtUser.Rows.Count > 0)
            {
                user = Map_PeopleDataRow_To_PeopleDomain(dtUser.Rows[0]);
            }
            return(user);
        }
Exemplo n.º 2
0
        public IPeople GetByOpenSiteDetails(int siteId, string siteUserId)
        {
            IPeople user = new MyDiary.Domain.Domains.People();

            user.UserRoles = new List <IRole>()
            {
                new Role()
            };
            user.UserImages = new List <IImage>()
            {
                new Image()
            };

            try
            {
                SqlConnection conn = SQLDbConnection.GetNewSqlConnectionObject();
                conn.Open();
                SqlCommand cmd = SQLDbConnection.GetNewSqlCommandObject(conn, Constants.StoredProcedures.People.DRY_USER_GET_BYOPENSITEDETAILS);
                cmd.Parameters.AddWithValue(Constants.StoredProcedures.People.Parameters.SiteId, siteId);
                cmd.Parameters.AddWithValue(Constants.StoredProcedures.People.Parameters.SiteUserId, siteUserId);
                DataTable dtUser = SQLDbConnection.FillDataSetFromDataAdapter(SQLDbConnection.GetNewSqlDataAdapterObject(cmd));
                if (dtUser != null && dtUser.Rows.Count > 0)
                {
                    user = Map_PeopleDataRow_To_PeopleDomain(dtUser.Rows[0]);
                }
                return(user);
            }
            catch (Exception)
            {
                return(user);
            }
        }
Exemplo n.º 3
0
        private IPeople Map_PeopleDataRow_To_PeopleDomain(DataRow drPeople)
        {
            IPeople      people    = new MyDiary.Domain.Domains.People();
            List <IRole> userRoles = new List <IRole>()
            {
                new Role()
            };
            List <IImage> userImages = new List <IImage>()
            {
                new Image()
            };

            foreach (DataColumn dc in drPeople.Table.Columns)
            {
                switch (dc.ColumnName)
                {
                case Constants.StoredProcedures.People.Fields.UserId:
                    people.UserId = (string.IsNullOrEmpty(drPeople[dc.ColumnName].ToString()) ? 0 : Convert.ToInt32(drPeople[dc.ColumnName].ToString()));
                    break;

                case Constants.StoredProcedures.People.Fields.FirstName:
                    people.FirstName = Convert.ToString(drPeople[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.People.Fields.MiddleName:
                    people.MiddleName = Convert.ToString(drPeople[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.People.Fields.LastName:
                    people.LastName = Convert.ToString(drPeople[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.People.Fields.EmailId:
                    people.EmailId = Convert.ToString(drPeople[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.People.Fields.RoleId:
                    userRoles.FirstOrDefault().RoleId = (string.IsNullOrEmpty(drPeople[dc.ColumnName].ToString()) ? 0 : Convert.ToInt32(drPeople[dc.ColumnName].ToString()));
                    break;

                case Constants.StoredProcedures.People.Fields.RoleName:
                    userRoles.FirstOrDefault().RoleCode = (drPeople[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.People.Fields.ImageId:
                    userImages.FirstOrDefault().ImageId = (string.IsNullOrEmpty(drPeople[dc.ColumnName].ToString()) ? 0 : Convert.ToInt32(drPeople[dc.ColumnName].ToString()));
                    break;

                case Constants.StoredProcedures.People.Fields.SiteId:
                    people.SiteId = (string.IsNullOrEmpty(drPeople[dc.ColumnName].ToString()) ? 0 : Convert.ToInt32(drPeople[dc.ColumnName].ToString()));
                    break;

                case Constants.StoredProcedures.People.Fields.SiteUserId:
                    people.SiteUserId = drPeople[dc.ColumnName].ToString();
                    break;
                }
            }

            people.UserImages = userImages;
            people.UserRoles  = userRoles;
            return(people);
        }
Exemplo n.º 4
0
        private IExpense GetExpenseFromDataRow(DataRow dr)
        {
            IExpense     expense     = new MyDiary.Domain.Domains.Expense();
            IExpenseType expenseType = new MyDiary.Domain.Domains.ExpenseType();
            IPeople      currentUser = new MyDiary.Domain.Domains.People();

            foreach (DataColumn dc in dr.Table.Columns)
            {
                switch (dc.ColumnName)
                {
                case Constants.StoredProcedures.Expenses.Parameters.ExpenseId:
                    expense.Id = Convert.ToInt32(dr[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.Expenses.Parameters.ExpenseType:
                    expenseType.Type = Convert.ToString(dr[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.Expenses.Parameters.ExpenseTypeId:
                    expenseType.TypeId = Convert.ToInt32(dr[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.Expenses.Parameters.ExpenseDate:
                    expense.ExpenseDate = Convert.ToDateTime(dr[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.Expenses.Parameters.Description:
                    expense.Description = Convert.ToString(dr[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.Expenses.Parameters.Comments:
                    expense.Comments = Convert.ToString(dr[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.Expenses.Parameters.Amount:
                    expense.Amount = float.Parse(dr[dc.ColumnName].ToString(), System.Globalization.CultureInfo.InvariantCulture);
                    break;

                case Constants.StoredProcedures.ExpenseTypes.Parameters.UserId:
                    currentUser.UserId = Convert.ToInt32(dr[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.Expenses.Parameters.CREATEDBY:
                    expense.CreatedBy = Convert.ToInt32(dr[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.Expenses.Parameters.CREATEDDATE:
                    expense.CreatedDate = Convert.ToDateTime(dr[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.Expenses.Parameters.MODIFIEDBY:
                    expense.ModifiedBy = (dr[dc.ColumnName]) == DBNull.Value ? (int?)null : Convert.ToInt32(dr[dc.ColumnName].ToString());
                    break;

                case Constants.StoredProcedures.Expenses.Parameters.MODIFIEDDATE:
                    expense.ModifiedDate = (dr[dc.ColumnName]) == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(dr[dc.ColumnName].ToString());
                    break;
                }
            }

            expense.ExpenseType = expenseType;
            expense.CurrentUser = currentUser;
            return(expense);
        }