Ejemplo n.º 1
0
        /// <summary>
        /// Gets the total number of records in the RoleMaster table based on search parameters
        /// </summary>
        internal static int GetRecordCountDynamicWhere(int?roleId, string roleDescription, DateTime?createdOn, string createdBy, DateTime?modifiedOn, string modifiedBy)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            int      roleIdValue     = int.MinValue;
            DateTime createdOnValue  = DateTime.MinValue;
            DateTime?modifiedOnValue = null;

            if (roleId != null)
            {
                roleIdValue = roleId.Value;
            }

            if (createdOn != null)
            {
                createdOnValue = createdOn.Value;
            }

            if (modifiedOn != null)
            {
                modifiedOnValue = modifiedOn.Value;
            }

            return(context.RoleMaster
                   .Where(r =>
                          (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                          (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                          (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                          (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                          (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                          (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                          ).Count());
        }
        /// <summary>
        /// Gets the total number of records in the UserMaster table based on search parameters
        /// </summary>
        internal static int GetRecordCountDynamicWhere(int?userId, string userName, string password, string email, DateTime?createdOn, string createdBy, DateTime?modifiedOn, string modifiedBy)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            int      userIdValue     = int.MinValue;
            DateTime createdOnValue  = DateTime.MinValue;
            DateTime?modifiedOnValue = null;

            if (userId != null)
            {
                userIdValue = userId.Value;
            }

            if (createdOn != null)
            {
                createdOnValue = createdOn.Value;
            }

            if (modifiedOn != null)
            {
                modifiedOnValue = modifiedOn.Value;
            }

            return(context.UserMaster
                   .Where(u =>
                          (userId != null ? u.UserId == userIdValue : 1 == 1) &&
                          (!String.IsNullOrEmpty(userName) ? u.UserName.Contains(userName) : 1 == 1) &&
                          (!String.IsNullOrEmpty(password) ? u.Password.Contains(password) : 1 == 1) &&
                          (!String.IsNullOrEmpty(email) ? u.Email.Contains(email) : 1 == 1) &&
                          (createdOn != null ? u.CreatedOn == createdOnValue : 1 == 1) &&
                          (!String.IsNullOrEmpty(createdBy) ? u.CreatedBy.Contains(createdBy) : 1 == 1) &&
                          (modifiedOn != null ? u.ModifiedOn == modifiedOnValue : 1 == 1) &&
                          (!String.IsNullOrEmpty(modifiedBy) ? u.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                          ).Count());
        }
        /// <summary>
        /// Selects UserRoleId and Status columns for use with a DropDownList web control
        /// </summary>
        internal static List <UserRoles> SelectUserRolesDropDownListData()
        {
            FirstTempdbContext context = new FirstTempdbContext();

            return((from u in context.UserRoles
                    select new UserRoles {
                UserRoleId = u.UserRoleId, Status = u.Status
            }).ToList());
        }
        /// <summary>
        /// Selects UserId and CreatedBy columns for use with a DropDownList web control
        /// </summary>
        internal static List <UserMaster> SelectUserMasterDropDownListData()
        {
            FirstTempdbContext context = new FirstTempdbContext();

            return((from u in context.UserMaster
                    select new UserMaster {
                UserId = u.UserId, CreatedBy = u.CreatedBy
            }).ToList());
        }
        /// <summary>
        /// Selects WorkflowId and WorkflowName columns for use with a DropDownList web control
        /// </summary>
        internal static List <WorkflowMaster> SelectWorkflowMasterDropDownListData()
        {
            FirstTempdbContext context = new FirstTempdbContext();

            return((from w in context.WorkflowMaster
                    select new WorkflowMaster {
                WorkflowId = w.WorkflowId, WorkflowName = w.WorkflowName
            }).ToList());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Selects RoleId and CreatedBy columns for use with a DropDownList web control
        /// </summary>
        internal static List <RoleMaster> SelectRoleMasterDropDownListData()
        {
            FirstTempdbContext context = new FirstTempdbContext();

            return((from r in context.RoleMaster
                    select new RoleMaster {
                RoleId = r.RoleId, CreatedBy = r.CreatedBy
            }).ToList());
        }
        /// <summary>
        /// Selects WorkflowMaster records sorted by the sortByExpression and returns records from the startRowIndex with rows (# of rows)
        /// </summary>
        internal static List <WorkflowMaster> SelectSkipAndTake(string sortByExpression, int startRowIndex, int rows)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            if (sortByExpression.Contains(" desc"))
            {
                switch (sortByExpression)
                {
                case "WorkflowName desc":
                    return(context.WorkflowMaster.OrderByDescending(w => w.WorkflowName).Skip(startRowIndex).Take(rows).ToList());

                case "LevelOfApprovals desc":
                    return(context.WorkflowMaster.OrderByDescending(w => w.LevelOfApprovals).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedBy desc":
                    return(context.WorkflowMaster.OrderByDescending(w => w.CreatedBy).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedOn desc":
                    return(context.WorkflowMaster.OrderByDescending(w => w.CreatedOn).Skip(startRowIndex).Take(rows).ToList());

                case "Updatedby desc":
                    return(context.WorkflowMaster.OrderByDescending(w => w.Updatedby).Skip(startRowIndex).Take(rows).ToList());

                case "Updatedon desc":
                    return(context.WorkflowMaster.OrderByDescending(w => w.Updatedon).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.WorkflowMaster.OrderByDescending(w => w.WorkflowId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
            else
            {
                switch (sortByExpression)
                {
                case "WorkflowName":
                    return(context.WorkflowMaster.OrderBy(w => w.WorkflowName).Skip(startRowIndex).Take(rows).ToList());

                case "LevelOfApprovals":
                    return(context.WorkflowMaster.OrderBy(w => w.LevelOfApprovals).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedBy":
                    return(context.WorkflowMaster.OrderBy(w => w.CreatedBy).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedOn":
                    return(context.WorkflowMaster.OrderBy(w => w.CreatedOn).Skip(startRowIndex).Take(rows).ToList());

                case "Updatedby":
                    return(context.WorkflowMaster.OrderBy(w => w.Updatedby).Skip(startRowIndex).Take(rows).ToList());

                case "Updatedon":
                    return(context.WorkflowMaster.OrderBy(w => w.Updatedon).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.WorkflowMaster.OrderBy(w => w.WorkflowId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Deletes a record based on primary key(s)
        /// </summary>
        internal static void Delete(int roleId)
        {
            FirstTempdbContext context = new FirstTempdbContext();
            var objRoleMaster          = context.RoleMaster.Where(r => r.RoleId == roleId).FirstOrDefault();

            if (objRoleMaster != null)
            {
                context.RoleMaster.Remove(objRoleMaster);
                context.SaveChanges();
            }
        }
        /// <summary>
        /// Deletes a record based on primary key(s)
        /// </summary>
        internal static void Delete(int userId)
        {
            FirstTempdbContext context = new FirstTempdbContext();
            var objUserMaster          = context.UserMaster.Where(u => u.UserId == userId).FirstOrDefault();

            if (objUserMaster != null)
            {
                context.UserMaster.Remove(objUserMaster);
                context.SaveChanges();
            }
        }
        /// <summary>
        /// Deletes a record based on primary key(s)
        /// </summary>
        internal static void Delete(int workflowId)
        {
            FirstTempdbContext context = new FirstTempdbContext();
            var objWorkflowMaster      = context.WorkflowMaster.Where(w => w.WorkflowId == workflowId).FirstOrDefault();

            if (objWorkflowMaster != null)
            {
                context.WorkflowMaster.Remove(objWorkflowMaster);
                context.SaveChanges();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Selects RoleMaster records sorted by the sortByExpression and returns records from the startRowIndex with rows (# of rows)
        /// </summary>
        internal static List <RoleMaster> SelectSkipAndTake(string sortByExpression, int startRowIndex, int rows)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            if (sortByExpression.Contains(" desc"))
            {
                switch (sortByExpression)
                {
                case "RoleDescription desc":
                    return(context.RoleMaster.OrderByDescending(r => r.RoleDescription).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedOn desc":
                    return(context.RoleMaster.OrderByDescending(r => r.CreatedOn).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedBy desc":
                    return(context.RoleMaster.OrderByDescending(r => r.CreatedBy).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedOn desc":
                    return(context.RoleMaster.OrderByDescending(r => r.ModifiedOn).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedBy desc":
                    return(context.RoleMaster.OrderByDescending(r => r.ModifiedBy).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.RoleMaster.OrderByDescending(r => r.RoleId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
            else
            {
                switch (sortByExpression)
                {
                case "RoleDescription":
                    return(context.RoleMaster.OrderBy(r => r.RoleDescription).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedOn":
                    return(context.RoleMaster.OrderBy(r => r.CreatedOn).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedBy":
                    return(context.RoleMaster.OrderBy(r => r.CreatedBy).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedOn":
                    return(context.RoleMaster.OrderBy(r => r.ModifiedOn).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedBy":
                    return(context.RoleMaster.OrderBy(r => r.ModifiedBy).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.RoleMaster.OrderBy(r => r.RoleId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
        }
        /// <summary>
        /// Updates a record
        /// </summary>
        internal static void Update(UserRoles objUserRoles)
        {
            FirstTempdbContext context      = new FirstTempdbContext();
            UserRoles          entUserRoles = context.UserRoles.Where(u => u.UserRoleId == objUserRoles.UserRoleId).FirstOrDefault();

            if (entUserRoles != null)
            {
                entUserRoles.UserId = objUserRoles.UserId;
                entUserRoles.RoleId = objUserRoles.RoleId;
                entUserRoles.Status = objUserRoles.Status;

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Inserts a record
        /// </summary>
        internal static int Insert(UserRoles objUserRoles)
        {
            FirstTempdbContext context      = new FirstTempdbContext();
            UserRoles          entUserRoles = new UserRoles();

            entUserRoles.UserId = objUserRoles.UserId;
            entUserRoles.RoleId = objUserRoles.RoleId;
            entUserRoles.Status = objUserRoles.Status;

            context.UserRoles.Add(entUserRoles);
            context.SaveChanges();

            return(entUserRoles.UserRoleId);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Inserts a record
        /// </summary>
        internal static int Insert(RoleMaster objRoleMaster)
        {
            FirstTempdbContext context       = new FirstTempdbContext();
            RoleMaster         entRoleMaster = new RoleMaster();

            entRoleMaster.RoleDescription = objRoleMaster.RoleDescription;
            entRoleMaster.CreatedOn       = objRoleMaster.CreatedOn;
            entRoleMaster.CreatedBy       = objRoleMaster.CreatedBy;
            entRoleMaster.ModifiedOn      = objRoleMaster.ModifiedOn;
            entRoleMaster.ModifiedBy      = objRoleMaster.ModifiedBy;

            context.RoleMaster.Add(entRoleMaster);
            context.SaveChanges();

            return(entRoleMaster.RoleId);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Updates a record
        /// </summary>
        internal static void Update(RoleMaster objRoleMaster)
        {
            FirstTempdbContext context       = new FirstTempdbContext();
            RoleMaster         entRoleMaster = context.RoleMaster.Where(r => r.RoleId == objRoleMaster.RoleId).FirstOrDefault();

            if (entRoleMaster != null)
            {
                entRoleMaster.RoleDescription = objRoleMaster.RoleDescription;
                entRoleMaster.CreatedOn       = objRoleMaster.CreatedOn;
                entRoleMaster.CreatedBy       = objRoleMaster.CreatedBy;
                entRoleMaster.ModifiedOn      = objRoleMaster.ModifiedOn;
                entRoleMaster.ModifiedBy      = objRoleMaster.ModifiedBy;

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Updates a record
        /// </summary>
        internal static void Update(WorkflowMaster objWorkflowMaster)
        {
            FirstTempdbContext context           = new FirstTempdbContext();
            WorkflowMaster     entWorkflowMaster = context.WorkflowMaster.Where(w => w.WorkflowId == objWorkflowMaster.WorkflowId).FirstOrDefault();

            if (entWorkflowMaster != null)
            {
                entWorkflowMaster.WorkflowName     = objWorkflowMaster.WorkflowName;
                entWorkflowMaster.LevelOfApprovals = objWorkflowMaster.LevelOfApprovals;
                entWorkflowMaster.CreatedBy        = objWorkflowMaster.CreatedBy;
                entWorkflowMaster.CreatedOn        = objWorkflowMaster.CreatedOn;
                entWorkflowMaster.Updatedby        = objWorkflowMaster.Updatedby;
                entWorkflowMaster.Updatedon        = objWorkflowMaster.Updatedon;

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Inserts a record
        /// </summary>
        internal static int Insert(WorkflowMaster objWorkflowMaster)
        {
            FirstTempdbContext context           = new FirstTempdbContext();
            WorkflowMaster     entWorkflowMaster = new WorkflowMaster();

            entWorkflowMaster.WorkflowName     = objWorkflowMaster.WorkflowName;
            entWorkflowMaster.LevelOfApprovals = objWorkflowMaster.LevelOfApprovals;
            entWorkflowMaster.CreatedBy        = objWorkflowMaster.CreatedBy;
            entWorkflowMaster.CreatedOn        = objWorkflowMaster.CreatedOn;
            entWorkflowMaster.Updatedby        = objWorkflowMaster.Updatedby;
            entWorkflowMaster.Updatedon        = objWorkflowMaster.Updatedon;

            context.WorkflowMaster.Add(entWorkflowMaster);
            context.SaveChanges();

            return(entWorkflowMaster.WorkflowId);
        }
        /// <summary>
        /// Inserts a record
        /// </summary>
        internal static int Insert(UserMaster objUserMaster)
        {
            FirstTempdbContext context       = new FirstTempdbContext();
            UserMaster         entUserMaster = new UserMaster();

            entUserMaster.UserName   = objUserMaster.UserName;
            entUserMaster.Password   = objUserMaster.Password;
            entUserMaster.Email      = objUserMaster.Email;
            entUserMaster.CreatedOn  = objUserMaster.CreatedOn;
            entUserMaster.CreatedBy  = objUserMaster.CreatedBy;
            entUserMaster.ModifiedOn = objUserMaster.ModifiedOn;
            entUserMaster.ModifiedBy = objUserMaster.ModifiedBy;

            context.UserMaster.Add(entUserMaster);
            context.SaveChanges();

            return(entUserMaster.UserId);
        }
        /// <summary>
        /// Updates a record
        /// </summary>
        internal static void Update(UserMaster objUserMaster)
        {
            FirstTempdbContext context       = new FirstTempdbContext();
            UserMaster         entUserMaster = context.UserMaster.Where(u => u.UserId == objUserMaster.UserId).FirstOrDefault();

            if (entUserMaster != null)
            {
                entUserMaster.UserName   = objUserMaster.UserName;
                entUserMaster.Password   = objUserMaster.Password;
                entUserMaster.Email      = objUserMaster.Email;
                entUserMaster.CreatedOn  = objUserMaster.CreatedOn;
                entUserMaster.CreatedBy  = objUserMaster.CreatedBy;
                entUserMaster.ModifiedOn = objUserMaster.ModifiedOn;
                entUserMaster.ModifiedBy = objUserMaster.ModifiedBy;

                context.SaveChanges();
            }
        }
        /// <summary>
        /// Gets the total number of records in the WorkflowMaster table based on search parameters
        /// </summary>
        internal static int GetRecordCountDynamicWhere(int?workflowId, string workflowName, int?levelOfApprovals, string createdBy, DateTime?createdOn, string updatedby, DateTime?updatedon)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            int      workflowIdValue       = int.MinValue;
            int      levelOfApprovalsValue = int.MinValue;
            DateTime createdOnValue        = DateTime.MinValue;
            DateTime updatedonValue        = DateTime.MinValue;

            if (workflowId != null)
            {
                workflowIdValue = workflowId.Value;
            }

            if (levelOfApprovals != null)
            {
                levelOfApprovalsValue = levelOfApprovals.Value;
            }

            if (createdOn != null)
            {
                createdOnValue = createdOn.Value;
            }

            if (updatedon != null)
            {
                updatedonValue = updatedon.Value;
            }

            return(context.WorkflowMaster
                   .Where(w =>
                          (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                          (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                          (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                          (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                          (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                          (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                          (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                          ).Count());
        }
        /// <summary>
        /// Selects records by RoleId as a collection (List) of UserRoles sorted by the sortByExpression and returns the rows (# of records) starting from the startRowIndex
        /// </summary>
        internal static List <UserRoles> SelectSkipAndTakeByRoleId(string sortByExpression, int startRowIndex, int rows, int roleId)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            if (sortByExpression.Contains(" desc"))
            {
                switch (sortByExpression)
                {
                case "UserId desc":
                    return(context.UserRoles.Where(u => u.RoleId == roleId).OrderByDescending(u => u.UserId).Skip(startRowIndex).Take(rows).ToList());

                case "RoleId desc":
                    return(context.UserRoles.Where(u => u.RoleId == roleId).OrderByDescending(u => u.RoleId).Skip(startRowIndex).Take(rows).ToList());

                case "Status desc":
                    return(context.UserRoles.Where(u => u.RoleId == roleId).OrderByDescending(u => u.Status).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.UserRoles.Where(u => u.RoleId == roleId).OrderByDescending(u => u.UserRoleId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
            else
            {
                switch (sortByExpression)
                {
                case "UserId":
                    return(context.UserRoles.Where(u => u.RoleId == roleId).OrderBy(u => u.UserId).Skip(startRowIndex).Take(rows).ToList());

                case "RoleId":
                    return(context.UserRoles.Where(u => u.RoleId == roleId).OrderBy(u => u.RoleId).Skip(startRowIndex).Take(rows).ToList());

                case "Status":
                    return(context.UserRoles.Where(u => u.RoleId == roleId).OrderBy(u => u.Status).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.UserRoles.Where(u => u.RoleId == roleId).OrderBy(u => u.UserRoleId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
        }
        /// <summary>
        /// Gets the total number of records in the UserRoles table based on search parameters
        /// </summary>
        internal static int GetRecordCountDynamicWhere(int?userRoleId, int?userId, int?roleId, bool?status)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            int  userRoleIdValue = int.MinValue;
            int  userIdValue     = int.MinValue;
            int  roleIdValue     = int.MinValue;
            bool statusValue     = false;

            if (userRoleId != null)
            {
                userRoleIdValue = userRoleId.Value;
            }

            if (userId != null)
            {
                userIdValue = userId.Value;
            }

            if (roleId != null)
            {
                roleIdValue = roleId.Value;
            }

            if (status != null)
            {
                statusValue = status.Value;
            }

            return(context.UserRoles
                   .Where(u =>
                          (userRoleId != null ? u.UserRoleId == userRoleIdValue : 1 == 1) &&
                          (userId != null ? u.UserId == userIdValue : 1 == 1) &&
                          (roleId != null ? u.RoleId == roleIdValue : 1 == 1) &&
                          (status != null ? u.Status == statusValue : 1 == 1)
                          ).Count());
        }
        /// <summary>
        /// Selects a record by primary key(s)
        /// </summary>
        internal static UserMaster SelectByPrimaryKey(int userId)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            return(context.UserMaster.Where(u => u.UserId == userId).FirstOrDefault());
        }
        /// <summary>
        /// Selects all WorkflowMaster
        /// </summary>
        internal static List <WorkflowMaster> SelectAll()
        {
            FirstTempdbContext context = new FirstTempdbContext();

            return(context.WorkflowMaster.ToList());
        }
        /// <summary>
        /// Gets the total number of records in the WorkflowMaster table
        /// </summary>
        internal static int GetRecordCount()
        {
            FirstTempdbContext context = new FirstTempdbContext();

            return(context.WorkflowMaster.Count());
        }
        /// <summary>
        /// Selects a record by primary key(s)
        /// </summary>
        internal static WorkflowMaster SelectByPrimaryKey(int workflowId)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            return(context.WorkflowMaster.Where(w => w.WorkflowId == workflowId).FirstOrDefault());
        }
        /// <summary>
        /// Selects WorkflowMaster records sorted by the sortByExpression and returns records from the startRowIndex with rows (# of records) based on search parameters
        /// </summary>
        internal static List <WorkflowMaster> SelectSkipAndTakeDynamicWhere(int?workflowId, string workflowName, int?levelOfApprovals, string createdBy, DateTime?createdOn, string updatedby, DateTime?updatedon, string sortByExpression, int startRowIndex, int rows)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            int      workflowIdValue       = int.MinValue;
            int      levelOfApprovalsValue = int.MinValue;
            DateTime createdOnValue        = DateTime.MinValue;
            DateTime updatedonValue        = DateTime.MinValue;

            if (workflowId != null)
            {
                workflowIdValue = workflowId.Value;
            }

            if (levelOfApprovals != null)
            {
                levelOfApprovalsValue = levelOfApprovals.Value;
            }

            if (createdOn != null)
            {
                createdOnValue = createdOn.Value;
            }

            if (updatedon != null)
            {
                updatedonValue = updatedon.Value;
            }

            if (sortByExpression.Contains(" desc"))
            {
                switch (sortByExpression)
                {
                case "WorkflowName desc":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderByDescending(w => w.WorkflowName).Skip(startRowIndex).Take(rows).ToList());

                case "LevelOfApprovals desc":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderByDescending(w => w.LevelOfApprovals).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedBy desc":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderByDescending(w => w.CreatedBy).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedOn desc":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderByDescending(w => w.CreatedOn).Skip(startRowIndex).Take(rows).ToList());

                case "Updatedby desc":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderByDescending(w => w.Updatedby).Skip(startRowIndex).Take(rows).ToList());

                case "Updatedon desc":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderByDescending(w => w.Updatedon).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderByDescending(w => w.WorkflowId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
            else
            {
                switch (sortByExpression)
                {
                case "WorkflowName":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderBy(w => w.WorkflowName).Skip(startRowIndex).Take(rows).ToList());

                case "LevelOfApprovals":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderBy(w => w.LevelOfApprovals).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedBy":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderBy(w => w.CreatedBy).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedOn":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderBy(w => w.CreatedOn).Skip(startRowIndex).Take(rows).ToList());

                case "Updatedby":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderBy(w => w.Updatedby).Skip(startRowIndex).Take(rows).ToList());

                case "Updatedon":
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderBy(w => w.Updatedon).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.WorkflowMaster
                           .Where(w =>
                                  (workflowId != null ? w.WorkflowId == workflowIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(workflowName) ? w.WorkflowName.Contains(workflowName) : 1 == 1) &&
                                  (levelOfApprovals != null ? w.LevelOfApprovals == levelOfApprovalsValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? w.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (createdOn != null ? w.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(updatedby) ? w.Updatedby.Contains(updatedby) : 1 == 1) &&
                                  (updatedon != null ? w.Updatedon == updatedonValue : 1 == 1)
                                  ).OrderBy(w => w.WorkflowId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
        }
        /// <summary>
        /// Selects UserMaster records sorted by the sortByExpression and returns records from the startRowIndex with rows (# of rows)
        /// </summary>
        internal static List <UserMaster> SelectSkipAndTake(string sortByExpression, int startRowIndex, int rows)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            if (sortByExpression.Contains(" desc"))
            {
                switch (sortByExpression)
                {
                case "UserName desc":
                    return(context.UserMaster.OrderByDescending(u => u.UserName).Skip(startRowIndex).Take(rows).ToList());

                case "Password desc":
                    return(context.UserMaster.OrderByDescending(u => u.Password).Skip(startRowIndex).Take(rows).ToList());

                case "Email desc":
                    return(context.UserMaster.OrderByDescending(u => u.Email).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedOn desc":
                    return(context.UserMaster.OrderByDescending(u => u.CreatedOn).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedBy desc":
                    return(context.UserMaster.OrderByDescending(u => u.CreatedBy).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedOn desc":
                    return(context.UserMaster.OrderByDescending(u => u.ModifiedOn).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedBy desc":
                    return(context.UserMaster.OrderByDescending(u => u.ModifiedBy).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.UserMaster.OrderByDescending(u => u.UserId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
            else
            {
                switch (sortByExpression)
                {
                case "UserName":
                    return(context.UserMaster.OrderBy(u => u.UserName).Skip(startRowIndex).Take(rows).ToList());

                case "Password":
                    return(context.UserMaster.OrderBy(u => u.Password).Skip(startRowIndex).Take(rows).ToList());

                case "Email":
                    return(context.UserMaster.OrderBy(u => u.Email).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedOn":
                    return(context.UserMaster.OrderBy(u => u.CreatedOn).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedBy":
                    return(context.UserMaster.OrderBy(u => u.CreatedBy).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedOn":
                    return(context.UserMaster.OrderBy(u => u.ModifiedOn).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedBy":
                    return(context.UserMaster.OrderBy(u => u.ModifiedBy).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.UserMaster.OrderBy(u => u.UserId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Selects RoleMaster records sorted by the sortByExpression and returns records from the startRowIndex with rows (# of records) based on search parameters
        /// </summary>
        internal static List <RoleMaster> SelectSkipAndTakeDynamicWhere(int?roleId, string roleDescription, DateTime?createdOn, string createdBy, DateTime?modifiedOn, string modifiedBy, string sortByExpression, int startRowIndex, int rows)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            int      roleIdValue     = int.MinValue;
            DateTime createdOnValue  = DateTime.MinValue;
            DateTime?modifiedOnValue = null;

            if (roleId != null)
            {
                roleIdValue = roleId.Value;
            }

            if (createdOn != null)
            {
                createdOnValue = createdOn.Value;
            }

            if (modifiedOn != null)
            {
                modifiedOnValue = modifiedOn.Value;
            }

            if (sortByExpression.Contains(" desc"))
            {
                switch (sortByExpression)
                {
                case "RoleDescription desc":
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderByDescending(r => r.RoleDescription).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedOn desc":
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderByDescending(r => r.CreatedOn).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedBy desc":
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderByDescending(r => r.CreatedBy).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedOn desc":
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderByDescending(r => r.ModifiedOn).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedBy desc":
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderByDescending(r => r.ModifiedBy).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderByDescending(r => r.RoleId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
            else
            {
                switch (sortByExpression)
                {
                case "RoleDescription":
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderBy(r => r.RoleDescription).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedOn":
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderBy(r => r.CreatedOn).Skip(startRowIndex).Take(rows).ToList());

                case "CreatedBy":
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderBy(r => r.CreatedBy).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedOn":
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderBy(r => r.ModifiedOn).Skip(startRowIndex).Take(rows).ToList());

                case "ModifiedBy":
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderBy(r => r.ModifiedBy).Skip(startRowIndex).Take(rows).ToList());

                default:
                    return(context.RoleMaster
                           .Where(r =>
                                  (roleId != null ? r.RoleId == roleIdValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(roleDescription) ? r.RoleDescription.Contains(roleDescription) : 1 == 1) &&
                                  (createdOn != null ? r.CreatedOn == createdOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(createdBy) ? r.CreatedBy.Contains(createdBy) : 1 == 1) &&
                                  (modifiedOn != null ? r.ModifiedOn == modifiedOnValue : 1 == 1) &&
                                  (!String.IsNullOrEmpty(modifiedBy) ? r.ModifiedBy.Contains(modifiedBy) : 1 == 1)
                                  ).OrderBy(r => r.RoleId).Skip(startRowIndex).Take(rows).ToList());
                }
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Selects a record by primary key(s)
        /// </summary>
        internal static RoleMaster SelectByPrimaryKey(int roleId)
        {
            FirstTempdbContext context = new FirstTempdbContext();

            return(context.RoleMaster.Where(r => r.RoleId == roleId).FirstOrDefault());
        }