Exemple #1
0
 /// <summary>
 /// Get the Role.
 /// </summary>
 /// <returns>Collection of Role.</returns>
 public IList <Role> GetRoles()
 {
     using (SqlConnection cn = new SqlConnection(_connectionString))
     {
         using (SqlCommand cmd = SqlHelper.GetSqlCommand(DbConstant.Role.StoreProcedure.usp_SelectUserRole, cn, true))
         {
             IList <Role> listRole = null;
             cn.Open();
             using (SqlDataReader reader = cmd.ExecuteReader())
             {
                 listRole = new List <Role>();
                 if (reader.HasRows)
                 {
                     while (reader.Read())
                     {
                         Role Role = new Role();
                         Role.Id          = TypeConversionUtility.ToInteger(reader[DbConstant.Role.DbColumn.Id]);
                         Role.RoleName    = TypeConversionUtility.ToStringWithNull(reader[DbConstant.Role.DbColumn.RoleName]);
                         Role.IsActive    = TypeConversionUtility.ToBoolean(reader[DbConstant.Role.DbColumn.IsActive]);
                         Role.CreatedDate = TypeConversionUtility.ToDateTime(reader[DbConstant.Role.DbColumn.CreatedDate]);
                         listRole.Add(Role);
                     }
                 }
                 cn.Close();
             }
             return(listRole);
         }
     }
 }
Exemple #2
0
        public List<UserOrderDiscount> GetOrderDiscounts(int userId)
        {
            using (SqlConnection cn = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = SqlHelper.GetSqlCommand(DbConstant.StoreProcedure.usp_GetOrderDiscount, cn, true))
                {
                    SqlParameter paramUserId = new SqlParameter(DbConstant.Parameter.UserId, userId);
                    cmd.Parameters.Add(paramUserId);

                    List<UserOrderDiscount> userPromoDiscounts = null;
                    cn.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        userPromoDiscounts = new List<UserOrderDiscount>();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                var data = new UserOrderDiscount
                                {
                                    Discount = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.Discount]),
                                    OrderNumber = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.OrderNumber]),
                                    TemplateId = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.TemplateId]),
                                    Savings = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.Savings]),
                                    GlobalPromoCode= TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.GlobalPromoCode])
                                };
                                userPromoDiscounts.Add(data);
                            }
                        }
                    }
                    return userPromoDiscounts;
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Get the Menus.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Collection of Menus.</returns>
        public IList <Role> GetMenus(int?id = null)
        {
            using (SqlConnection cn = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = SqlHelper.GetSqlCommand(DbConstant.Role.StoreProcedure.usp_SelectMenuOrSubMenu, cn, true))
                {
                    SqlParameter paramId = new SqlParameter(DbConstant.Role.DbParameter.Id, id);
                    cmd.Parameters.Add(paramId);

                    IList <Role> listRole = null;
                    cn.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        listRole = new List <Role>();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                Role Role = new Role();
                                Role.MenuId      = TypeConversionUtility.ToInteger(reader[DbConstant.Role.DbColumn.MenuId]);
                                Role.MenuName    = TypeConversionUtility.ToStringWithNull(reader[DbConstant.Role.DbColumn.MenuName]);
                                Role.SubMenuId   = TypeConversionUtility.ToInteger(reader[DbConstant.Role.DbColumn.SubMenuId]);
                                Role.SubMenuName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.Role.DbColumn.SubMenuName]);
                                Role.MenuLink    = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.MenuLink]);
                                listRole.Add(Role);
                            }
                        }
                        cn.Close();
                    }
                    return(listRole);
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// Get the SubMenu.
 /// </summary>
 /// <returns>Collection of SubMenu.</returns>
 public IList<SubMenu> GetSubMenus()
 {
     using (SqlConnection cn = new SqlConnection(_connectionString))
     {
         using (SqlCommand cmd = SqlHelper.GetSqlCommand(DbConstant.SubMenu.StoreProcedure.usp_SelectSubMenu, cn, true))
         {
             IList<SubMenu> SubMenus = null;
             cn.Open();
             using (SqlDataReader reader = cmd.ExecuteReader())
             {
                 SubMenus = new List<SubMenu>();
                 if (reader.HasRows)
                 {
                     while (reader.Read())
                     {
                         SubMenu SubMenu = new SubMenu();
                         SubMenu.Id = TypeConversionUtility.ToInteger(reader[DbConstant.SubMenu.DbColumn.Id]);
                         SubMenu.MenuName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.MenuName]);
                         SubMenu.SubMenuName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.SubMenuName]);
                         SubMenu.MenuId = TypeConversionUtility.ToInteger(reader[DbConstant.SubMenu.DbColumn.MenuId]);
                         SubMenu.DisplayOrder = TypeConversionUtility.ToInteger(reader[DbConstant.SubMenu.DbColumn.DisplayOrder]);
                         SubMenu.IsActive = TypeConversionUtility.ToBoolean(reader[DbConstant.SubMenu.DbColumn.IsActive]);
                         SubMenu.CreatedDate = TypeConversionUtility.ToDateTime(reader[DbConstant.SubMenu.DbColumn.CreatedDate]);
                         SubMenus.Add(SubMenu);
                     }
                 }
                 cn.Close();
             }
             return SubMenus;
         }
     }
 }
Exemple #5
0
 /// <summary>
 /// Get the Menu.
 /// </summary>
 /// <returns>Collection of Menu.</returns>
 public IList<MenuNav> GetMenus()
 {
     using (SqlConnection cn = new SqlConnection(_connectionString))
     {
         using (SqlCommand cmd = SqlHelper.GetSqlCommand(DbConstant.Menu.StoreProcedure.usp_SelectMenu, cn, true))
         {
             IList<MenuNav> listMenuNav = null;
             cn.Open();
             using (SqlDataReader reader = cmd.ExecuteReader())
             {
                 listMenuNav = new List<MenuNav>();
                 if (reader.HasRows)
                 {
                     while (reader.Read())
                     {
                         MenuNav menuNav = new MenuNav();
                         menuNav.Id = TypeConversionUtility.ToInteger(reader[DbConstant.Menu.DbColumn.Id]);
                         menuNav.MenuName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.Menu.DbColumn.MenuName]);
                         menuNav.DisplayOrder = TypeConversionUtility.ToInteger(reader[DbConstant.Menu.DbColumn.DisplayOrder]);
                         menuNav.IsActive = TypeConversionUtility.ToBoolean(reader[DbConstant.Menu.DbColumn.IsActive]);
                         menuNav.CreatedDate = TypeConversionUtility.ToDateTime(reader[DbConstant.Menu.DbColumn.CreatedDate]);
                         listMenuNav.Add(menuNav);
                     }
                 }
                 cn.Close();
             }
             return listMenuNav;
         }
     }
 }
Exemple #6
0
        /// <summary>
        /// Get the Menus By Role.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Collection of Menus.</returns>
        public IList<MenuNav> GetMenusByRole(int? roleId = null)
        {
            using (SqlConnection cn = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = SqlHelper.GetSqlCommand(DbConstant.Menu.StoreProcedure.usp_SelectRoleByMenu, cn, true))
                {
                    SqlParameter paramRoleId = new SqlParameter(DbConstant.Menu.DbParameter.RoleId, roleId);
                    cmd.Parameters.Add(paramRoleId);

                    IList<MenuNav> listMenuNav = null;
                    cn.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        listMenuNav = new List<MenuNav>();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                MenuNav menuNav = new MenuNav();
                                menuNav.Id = TypeConversionUtility.ToInteger(reader[DbConstant.Role.DbColumn.Id]);
                                menuNav.MenuName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.Role.DbColumn.MenuName]);
                                listMenuNav.Add(menuNav);
                            }
                        }
                        cn.Close();
                    }
                    return listMenuNav;
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Gets the user based on User ID.
        /// </summary>
        /// <param name="userId">The User ID to be loaded.</param>
        /// <param name="emailAddress">The email address.</param>
        /// <param name="password">The password.</param>
        /// <param name="status">The status.</param>
        /// <returns>Object of <see cref="User" />.</returns>
        public User GetUser(int? userId, string emailAddress, string password, Enums.Status status)
        {
            using (SqlConnection cn = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = SqlHelper.GetSqlCommand(DbConstant.StoreProcedure.usp_GetUser, cn, true))
                {
                    SqlParameter paramUserId = new SqlParameter(DbConstant.Parameter.Id, userId);
                    cmd.Parameters.Add(paramUserId);

                    SqlParameter paramEmailAddress = new SqlParameter(DbConstant.Parameter.Email, emailAddress);
                    cmd.Parameters.Add(paramEmailAddress);

                    SqlParameter paramPassword = new SqlParameter(DbConstant.Parameter.Password, password);
                    cmd.Parameters.Add(paramPassword);

                    if (status != Enums.Status.NotDefined)
                    {
                        SqlParameter paramStatus = new SqlParameter(DbConstant.Parameter.Status, status);
                        cmd.Parameters.Add(paramStatus);
                    }

                    User user = null;
                    cn.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {

                        if (reader.HasRows)
                        {
                            if (reader.Read())
                            {
                                user = new User();
                                user.Id = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.Id]);
                                user.FirstName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.FirstName]);
                                user.LastName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.LastName]);
                                user.Status = (Enums.Status)TypeConversionUtility.ToByte(reader[DbConstant.DbColumn.Status]);
                                user.UserType = (Enums.UserType)TypeConversionUtility.ToByte(reader[DbConstant.DbColumn.UserType]);
                                user.Email = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.Email]);
                                user.Password = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.Password]);
                                user.ProfileImage = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.ProfileImage]);
                                user.PhoneNumber = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.PhoneNumber]);
                                user.SchoolName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.SchoolName]);
                                user.DateCreated = TypeConversionUtility.ToDateTime(reader[DbConstant.DbColumn.DateCreated]);
                                user.PromoCode = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.PromoCode]);
                                user.SYId = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.SYId]);
                                user.IsGiftFree = TypeConversionUtility.ToBoolean(reader[DbConstant.DbColumn.IsGiftFree]);
                                user.IsTaxExempt = TypeConversionUtility.ToBoolean(reader[DbConstant.DbColumn.IsTaxExempt]);
                                user.RoleId = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.RoleId]);

                            }
                        }
                    }
                    return user;
                }
            }
        }
        protected void lkbSubmit_OnClick(object sender, EventArgs e)
        {
            try
            {
                var objUser = new clsUser();
                if (!string.IsNullOrEmpty(Convert.ToString(Request.QueryString["Id"])))
                {
                    objUser.UserId = TypeConversionUtility.ToInteger(Request.QueryString["Id"]);
                }
                else
                {
                    objUser.UserId = 0;
                }
                objUser.UserName = TypeConversionUtility.ToStringWithNull(txtName.Text.Trim());
                objUser.EmailId  = TypeConversionUtility.ToStringWithNull(txtEmailId.Text.Trim());
                objUser.LoginId  = TypeConversionUtility.ToStringWithNull(txtLoginId.Text.Trim());
                objUser.LoginPwd = TypeConversionUtility.ToStringWithNull(txtPwd.Text.Trim());
                objUser.Status   = TypeConversionUtility.ToInteger(ddlStatus.SelectedValue);
                objUser.TypeId   = Convert.ToInt32(ddUserLevel.SelectedValue);

                if (UserRepository.CheckUserExits(objUser.UserId, objUser.LoginId))
                {
                    lblMsg.Text    = "Login Id already exist. Try using different login id.";
                    pnlMsg.Visible = true;
                }
                else if (UserRepository.UserAddUpdate(objUser)) // Add/Update Login Details
                {
                    if (objUser.UserId == 0)
                    {
                        pnlMsg.Visible          = true;
                        lblMsg.Text             = "Record has been successfully inserted.";
                        lblMsg.CssClass         = "success";
                        txtName.Text            = "";
                        txtEmailId.Text         = "";
                        txtPwd.Text             = "";
                        txtLoginId.Text         = "";
                        ddlStatus.SelectedValue = "0";
                    }
                    else
                    {
                        Response.Redirect("userList.aspx?msg=Record has been successfully updated.");
                    }
                }
            }
            catch (Exception ex)
            {
                lblMsg.Text    = string.Format("<p class=\"error\">{0}</p>", ex);
                pnlMsg.Visible = true;
            }
        }
Exemple #9
0
        /// <summary>
        /// Get the SubMenu.
        /// </summary>
        /// <returns>Details of SubMenu.</returns>
        public SubMenu GetSubMenu(int id,bool ? isAddPage)
        {
            using (SqlConnection cn = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = SqlHelper.GetSqlCommand(DbConstant.SubMenu.StoreProcedure.usp_SelectSubMenu, cn, true))
                {
                    SqlParameter paramId = new SqlParameter(DbConstant.SubMenu.DbParameter.Id, id);
                    cmd.Parameters.Add(paramId);

                    SqlParameter paramIsAddPage = new SqlParameter(DbConstant.SubMenu.DbParameter.IsAddPage, isAddPage);
                    cmd.Parameters.Add(paramIsAddPage);

                    SubMenu subMenus = null;
                    cn.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        subMenus = new SubMenu();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                subMenus.Id = TypeConversionUtility.ToInteger(reader[DbConstant.SubMenu.DbColumn.Id]);
                                subMenus.MenuName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.MenuName]);
                                subMenus.MenuLink = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.MenuLink]);
                                subMenus.SubMenuName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.SubMenuName]);
                                subMenus.ListPageHeading = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.ListPageHeading]);
                                subMenus.ListPageDescription = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.ListPageDescription]);
                                subMenus.AddPageHeading = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.AddPageHeading]);
                                subMenus.AddPageDescription = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.AddPageDescription]);
                                subMenus.IsAddPage = TypeConversionUtility.ToBoolean(reader[DbConstant.SubMenu.DbColumn.IsAddPage]);
                                subMenus.MenuId = TypeConversionUtility.ToInteger(reader[DbConstant.SubMenu.DbColumn.MenuId]);
                                subMenus.DisplayOrder = TypeConversionUtility.ToInteger(reader[DbConstant.SubMenu.DbColumn.DisplayOrder]);
                                subMenus.IsActive = TypeConversionUtility.ToBoolean(reader[DbConstant.SubMenu.DbColumn.IsActive]);
                                subMenus.CreatedDate = TypeConversionUtility.ToDateTime(reader[DbConstant.SubMenu.DbColumn.CreatedDate]);
                            }
                        }
                        cn.Close();
                    }
                    return subMenus;
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// Get the Sub Menus by Role.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="roleId"></param>
        /// <returns>Collection of Sub Menus.</returns>
        public IList<SubMenu> GetSubMenusByRole(int? id = null, int ? roleId = null)
        {
            using (SqlConnection cn = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = SqlHelper.GetSqlCommand(DbConstant.SubMenu.StoreProcedure.usp_SelectSubMenuByRole, cn, true))
                {
                    SqlParameter paramId = new SqlParameter(DbConstant.Role.DbParameter.Id, id);
                    cmd.Parameters.Add(paramId);

                    SqlParameter paramRoleId = new SqlParameter(DbConstant.Menu.DbParameter.RoleId, roleId);
                    cmd.Parameters.Add(paramRoleId);

                    IList<SubMenu> listSubMenu = null;
                    cn.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        listSubMenu = new List<SubMenu>();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                SubMenu subMenu = new SubMenu();
                                subMenu.Id = TypeConversionUtility.ToInteger(reader[DbConstant.SubMenu.DbColumn.Id]);
                                subMenu.MenuId = TypeConversionUtility.ToInteger(reader[DbConstant.SubMenu.DbColumn.MenuId]);
                                subMenu.MenuName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.MenuName]);
                                subMenu.SubMenuName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.SubMenuName]);
                                subMenu.MenuLink = TypeConversionUtility.ToStringWithNull(reader[DbConstant.SubMenu.DbColumn.MenuLink]);
                                listSubMenu.Add(subMenu);
                            }
                        }
                        cn.Close();
                    }
                    return listSubMenu;
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// Get the Users Paged.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="startPage">Page number at which to start reading.</param>
        /// <param name="pageLength">Number of records to be displayed per page.</param>
        /// <param name="noOfPages">Out parameter which returns the number of pages.</param>
        /// <param name="totalRecords">Out parameter which returns the total records.</param>
        /// <param name="email"></param>
        /// <returns>Collection of User.</returns>
        public IList<User> GetUsers(string email, string name, int startPage, int pageLength, out int noOfPages, out int totalRecords)
        {
            using (SqlConnection cn = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = SqlHelper.GetSqlCommand(DbConstant.StoreProcedure.usp_GetUsersPaged, cn, true))
                {

                    SqlParameter paramName = new SqlParameter(DbConstant.Parameter.Name, name);
                    cmd.Parameters.Add(paramName);

                    SqlParameter paramEmailAddress = new SqlParameter(DbConstant.Parameter.Email, email);
                    cmd.Parameters.Add(paramEmailAddress);

                    SqlParameter parStart = new SqlParameter(DbConstant.Parameter.StartPage, startPage);
                    cmd.Parameters.Add(parStart);

                    SqlParameter parPageLength = new SqlParameter(DbConstant.Parameter.PageLength, pageLength);
                    cmd.Parameters.Add(parPageLength);

                    SqlParameter parNoOfPage = new SqlParameter(DbConstant.Parameter.NoOfPages, noOfPages = 0);
                    parNoOfPage.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(parNoOfPage);

                    SqlParameter partotalRecords = new SqlParameter(DbConstant.Parameter.TotalRecords, totalRecords = 0);
                    partotalRecords.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(partotalRecords);

                    IList<User> users = null;
                    cn.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        users = new List<User>();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                var user = new User();
                                user.Id = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.Id]);
                                user.FirstName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.FirstName]);
                                user.LastName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.LastName]);
                                user.Password = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.Password]);
                                user.Status = (Enums.Status)TypeConversionUtility.ToByte(reader[DbConstant.DbColumn.Status]);
                                user.UserType = (Enums.UserType)TypeConversionUtility.ToByte(reader[DbConstant.DbColumn.UserType]);
                                user.Email = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.Email]);
                                user.ProfileImage = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.ProfileImage]);
                                user.PhoneNumber = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.PhoneNumber]);
                                user.SchoolName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.SchoolName]);
                                user.DateCreated = TypeConversionUtility.ToDateTime(reader[DbConstant.DbColumn.DateCreated]);
                                user.AccountType.Id = TypeConversionUtility.ToByte(reader[DbConstant.DbColumn.AccountType]);
                                user.AccountCategory.CategoryName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.CategoryName]);
                                user.SYId = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.SYId]);
                                users.Add(user);
                            }
                        }
                        cn.Close();
                        if (reader.IsClosed)
                        {
                            noOfPages = TypeConversionUtility.ToInteger(parNoOfPage.Value);
                            totalRecords = TypeConversionUtility.ToInteger(partotalRecords.Value);
                        }
                    }

                    return users;
                }
            }
        }
Exemple #12
0
        /// <summary>
        /// Gets the user based on User ID.
        /// </summary>
        /// <param name="userId">The User ID to be loaded.</param>
        /// <param name="emailAddress">The email address.</param>
        /// <param name="password">The password.</param>
        /// <param name="status">The status.</param>
        /// <returns>Object of <see cref="User" />.</returns>
        public User GetUserProfile(int? userId, string emailAddress, string password, Enums.Status status)
        {
            using (SqlConnection cn = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = SqlHelper.GetSqlCommand(DbConstant.StoreProcedure.usp_GetUserProfile, cn, true))
                {
                    SqlParameter paramUserId = new SqlParameter(DbConstant.Parameter.Id, userId);
                    cmd.Parameters.Add(paramUserId);


                    User user = null;
                    cn.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {

                        if (reader.HasRows)
                        {
                            if (reader.Read())
                            {
                                user = new User();
                                user.Id = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.Id]);
                                user.FirstName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.FirstName]);
                                user.LastName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.LastName]);
                                user.Status = (Enums.Status)TypeConversionUtility.ToByte(reader[DbConstant.DbColumn.Status]);
                                user.UserType = (Enums.UserType)TypeConversionUtility.ToByte(reader[DbConstant.DbColumn.UserType]);
                                user.Email = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.Email]);
                                user.Password = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.Password]);
                                user.ProfileImage = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.ProfileImage]);
                                user.PhoneNumber = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.PhoneNumber]);
                                user.SchoolName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.SchoolName]);
                                user.DateCreated = TypeConversionUtility.ToDateTime(reader[DbConstant.DbColumn.DateCreated]);
                                user.PromoCode = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.PromoCode]);
                                user.SYId = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.SYId]);
                                user.AccountType.Id = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.AccountType]);
                                user.PromoType = (Enums.PromoType)TypeConversionUtility.ToByte(reader[DbConstant.DbColumn.PromoType]);
                                user.IsGiftFree = TypeConversionUtility.ToBoolean(reader[DbConstant.DbColumn.IsGiftFree]);
                                user.PhoneNumberType = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.PhoneNumberType]);
                                user.Address1 = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.Address1]);
                                user.Address2 = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.Address2]);
                                user.City = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.City]);
                                user.ZipCode = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.ZipCode]);
                                user.SchoolDistrict = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.SchoolDistrict]);
                                user.ApprovedVendor = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.ApprovedVendor]);
                                user.IsTaxExempt = TypeConversionUtility.ToBoolean(reader[DbConstant.DbColumn.IsTaxExempt]);
                                user.TaxExempt = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.TaxExempt]);
                                user.TaxExemptFile = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.TaxExemptFile]);

                                user.AccountCategory.Id = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.AccountCategory]);
                                user.AccountCategory.CategoryName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.CategoryName]);
                                user.AccountCategory.IsOther = TypeConversionUtility.ToBoolean(reader[DbConstant.DbColumn.IsOtherCategoryName]);

                                user.SchoolCampus.Id = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.SchoolCampusId]);
                                user.SchoolCampus.CampusName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.CampusName]);
                                user.SchoolCampus.IsOther = TypeConversionUtility.ToBoolean(reader[DbConstant.DbColumn.IsOtherCampus]);

                                user.SchoolType.Id = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.SchoolTypeId]);
                                user.SchoolType.IsOther = TypeConversionUtility.ToBoolean(reader[DbConstant.DbColumn.IsOtherSchoolType]);
                                user.SchoolType.SchoolTypeName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.SchoolTypeName]);

                                user.State.Id = TypeConversionUtility.ToInteger(reader[DbConstant.DbColumn.StateId]);
                                user.State.StateName = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.StateName]);
                                user.State.StateCode = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.StateCode]);
                                user.State.IsOther = TypeConversionUtility.ToBoolean(reader[DbConstant.DbColumn.IsOtherState]);
                                user.IsSchoolDistrictExempt = TypeConversionUtility.ToBoolean(reader[DbConstant.DbColumn.IsSchoolDistrictExempt]);
                                user.IsActiveCategory = TypeConversionUtility.ToBoolean(reader[DbConstant.DbColumn.IsActiveCategory]);
                                user.IsProfile = true;
                                user.IsNotifications = TypeConversionUtility.ToBoolean(reader[DbConstant.DbColumn.IsNotifications]);
                                user.CellPhone = TypeConversionUtility.ToStringWithNull(reader[DbConstant.DbColumn.CellPhone]);
                            }
                        }
                    }
                    return user;
                }
            }
        }