Пример #1
0
        public override string[] GetRolesForUser(string username)
        {
            //using (EmployeeDBContext context = new EmployeeDBContext())
            //{
            //var userRoles = (from user in context.Users
            //                 join roleMapping in context.UserRolesMappings
            //                 on user.ID equals roleMapping.UserID
            //                 join role in context.RoleMasters
            //                 on roleMapping.RoleID equals role.ID
            //                 where user.UserName == username
            //                 select role.RollName).ToArray();
            Tbl_LoginBusinessModelLayers tbl_loginBusinessModelLayers = new Tbl_LoginBusinessModelLayers();

            BusinessModelLayer.Tbl_LoginSingle tbl_login = tbl_loginBusinessModelLayers.GetAllTbl_Logins().FirstOrDefault(x => x.Username == username);
            var userRoles = "User".Split(',').ToArray();

            if (tbl_login != null)
            {
                userRoles = tbl_login.Roles.Split(',').ToArray();
            }
            return(userRoles);
            //}
        }
Пример #2
0
        public ActionResult Details(string Username)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    Tbl_LoginBusinessModelLayers tbl_loginBusinessModelLayers = new Tbl_LoginBusinessModelLayers();

                    BusinessModelLayer.Tbl_LoginSingle tbl_login = tbl_loginBusinessModelLayers.GetAllTbl_Logins().FirstOrDefault(x => x.Username == Username);

                    return(View(tbl_login));
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #3
0
        public ViewResult List(string sortOrder, string currentFilter, string searchString, int?page, string PgeSize)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    ViewBag.CurrentSort      = sortOrder;
                    ViewBag.UsernameSortParm = String.IsNullOrEmpty(sortOrder) ? "Username_desc" : "";

                    BusinessLayer.Validation pge      = new BusinessLayer.Validation();
                    List <SelectListItem>    PgeSizes = pge.PageSize();

                    //Assigning generic list to ViewBag
                    ViewBag.PgeSizeList = PgeSizes;

                    if (searchString != null)
                    {
                        page = 1;
                    }
                    else
                    {
                        searchString = currentFilter;
                    }

                    ViewBag.CurrentFilter = searchString;

                    Tbl_LoginBusinessModelLayers          tbl_loginBusinessModelLayers = new Tbl_LoginBusinessModelLayers();
                    List <BusinessModelLayer.Vwtbl_login> vwtbl_logins = tbl_loginBusinessModelLayers.GetAllVwtbl_logins();

                    if (!String.IsNullOrEmpty(searchString))
                    {
                        vwtbl_logins = vwtbl_logins.Where(s => s.Username.ToString().ToLower().Contains(searchString.ToLower())).ToList();
                    }

                    switch (sortOrder)
                    {
                    case "Username_desc":
                        vwtbl_logins = vwtbl_logins.OrderByDescending(s => s.Username).ToList();
                        break;

                    //case "!!!":
                    //	vwtbl_logins = vwtbl_logins.OrderBy(s => s.!!!).ToList();
                    //	break;
                    //case "!!!_desc":
                    //	vwtbl_logins = vwtbl_logins.OrderByDescending(s => s.!!!).ToList();
                    //	break;
                    default:      // Username ascending
                        vwtbl_logins = vwtbl_logins.OrderBy(s => s.Username).ToList();
                        break;
                    }

                    int pageSize = 10;
                    if (PgeSize != null)
                    {
                        Int32.TryParse(PgeSize, out pageSize);
                    }
                    ViewBag.PgeSize = pageSize;
                    int pageNumber = (page ?? 1);
                    return(View(vwtbl_logins.ToPagedList(pageNumber, pageSize)));
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }