/// <summary>
        /// Used when adding or updating a record.
        /// </summary>
        internal static void AddOrEdit(RoleMaster model, CrudOperation operation, bool isForListInline = false)
        {
            RoleMaster objRoleMaster;
            RoleMaster objRoleMasterOld = new RoleMaster();
            decimal    id = 0;

            if (operation == CrudOperation.Add)
            {
                objRoleMaster = new RoleMaster();
            }
            else
            {
                objRoleMaster    = RoleMaster.SelectByPrimaryKey(model.RoleId);
                objRoleMasterOld = objRoleMaster.ShallowCopy();
            }

            objRoleMaster.RoleId          = model.RoleId;
            objRoleMaster.RoleDescription = model.RoleDescription;
            objRoleMaster.CreatedOn       = model.CreatedOn;
            objRoleMaster.CreatedBy       = model.CreatedBy;
            objRoleMaster.ModifiedOn      = model.ModifiedOn;
            objRoleMaster.ModifiedBy      = model.ModifiedBy;

            if (operation == CrudOperation.Add)
            {
                id = objRoleMaster.Insert();
            }
            else
            {
                objRoleMaster.Update();
            }
        }
        /// <summary>
        /// Handler, deletes a record.
        /// </summary>
        public IActionResult OnGetRemove(int id)
        {
            RoleMaster RoleMaster = RoleMaster.SelectByPrimaryKey(id);

            RoleMaster.Delete(id);
            return(new JsonResult(true));
        }
예제 #3
0
    /// <summary>
    /// Shows how to Select a record by Primary Key.  It also shows how to retrieve Lazily-loaded related Objects.  Related Objects are assigned for each Foreign Key.
    /// </summary>
    private void SelectByPrimaryKey()
    {
        int userRoleIdSample = 1;

        // select a record by primary key(s)

        UserRoles objUserRoles = UserRoles.SelectByPrimaryKey(userRoleIdSample);

        if (objUserRoles != null)
        {
            // if record is found, a record is returned
            int  userRoleId = objUserRoles.UserRoleId;
            int? userId     = objUserRoles.UserId;
            int? roleId     = objUserRoles.RoleId;
            bool?status     = objUserRoles.Status;

            // get the UserMaster related to UserId.
            if (objUserRoles.UserId != null)
            {
                UserMaster objUserMasterRelatedToUserId = UserMaster.SelectByPrimaryKey(userId.Value);
            }

            // get the RoleMaster related to RoleId.
            if (objUserRoles.RoleId != null)
            {
                RoleMaster objRoleMasterRelatedToRoleId = RoleMaster.SelectByPrimaryKey(roleId.Value);
            }
        }
    }
예제 #4
0
        public void LoadPage(int id, string returnUrl)
        {
            // select a record by primary key(s)
            fifth_tempDBAPI.BusinessObject.RoleMaster objRoleMaster = RoleMaster.SelectByPrimaryKey(id);

            // assign values to this page's bound property
            RoleMaster = objRoleMaster;

            // assign the return url
            ReturnUrl = returnUrl;
        }
예제 #5
0
    /// <summary>
    /// Shows how to Select a record by Primary Key.  It also shows how to retrieve Lazily-loaded related Objects.  Related Objects are assigned for each Foreign Key.
    /// </summary>
    private void SelectByPrimaryKey()
    {
        int roleIdSample = 1;

        // select a record by primary key(s)

        RoleMaster objRoleMaster = RoleMaster.SelectByPrimaryKey(roleIdSample);

        if (objRoleMaster != null)
        {
            // if record is found, a record is returned
            int      roleId          = objRoleMaster.RoleId;
            string   roleDescription = objRoleMaster.RoleDescription;
            DateTime createdOn       = objRoleMaster.CreatedOn;
            string   createdBy       = objRoleMaster.CreatedBy;
            DateTime?modifiedOn      = objRoleMaster.ModifiedOn;
            string   modifiedBy      = objRoleMaster.ModifiedBy;
        }
    }
예제 #6
0
        public PageResult LoadPage(int id, string returnUrl)
        {
            // select a record by primary key(s)
            CourseEnquiryAPI.BusinessObject.RoleMaster objRoleMaster = RoleMaster.SelectByPrimaryKey(id);

            // create the model used by the partial page
            AddEditRoleMasterPartialModel model = new AddEditRoleMasterPartialModel();

            model.Operation  = CrudOperation.Update;
            model.ReturnUrl  = returnUrl;
            model.RoleMaster = objRoleMaster;

            // assign values to the model used by this page
            PartialModel = model;

            // assign the return url
            ReturnUrl = returnUrl;

            return(Page());
        }
예제 #7
0
    /// <summary>
    /// Shows how to Select all records by RoleMaster, related to column RoleId
    /// </summary>
    private void SelectUserRolesCollectionByRoleId()
    {
        int roleIdSample = 1;

        List <UserRoles> objUserRolesCol = UserRoles.SelectUserRolesCollectionByRoleId(roleIdSample);

        // Example 1:  you can optionally sort the collection in ascending order by your chosen field
        objUserRolesCol.Sort(UserRoles.ByUserId);

        // Example 2:  to sort in descending order, add this line to the Sort code in Example 1
        objUserRolesCol.Reverse();

        // Example 3:  directly bind to a GridView - for ASP.NET Web Forms
        // GridView grid = new GridView();
        // grid.DataSource = objUserRolesCol;
        // grid.DataBind();

        // Example 4:  loop through all the UserRoles(s)
        foreach (UserRoles objUserRoles in objUserRolesCol)
        {
            int  userRoleId = objUserRoles.UserRoleId;
            int? userId     = objUserRoles.UserId;
            int? roleId     = objUserRoles.RoleId;
            bool?status     = objUserRoles.Status;

            // get the UserMaster related to UserId.
            if (objUserRoles.UserId != null)
            {
                UserMaster objUserMasterRelatedToUserId = UserMaster.SelectByPrimaryKey(userId.Value);
            }

            // get the RoleMaster related to RoleId.
            if (objUserRoles.RoleId != null)
            {
                RoleMaster objRoleMasterRelatedToRoleId = RoleMaster.SelectByPrimaryKey(roleId.Value);
            }
        }
    }