コード例 #1
0
        /// <summary>
        /// Adds a single report role to the repository
        /// </summary>
        /// <param name="role">The role to add</param>
        public void AddRole
        (
            ReportRole role
        )
        {
            Validate.IsNotNull(role);

            _context.Set <ReportRole>().Add
            (
                role
            );
        }
コード例 #2
0
        /// <summary>
        /// Updates a single report role to the repository
        /// </summary>
        /// <param name="role">The role to update</param>
        public void UpdateRole
        (
            ReportRole role
        )
        {
            Validate.IsNotNull(role);

            var entry = _context.Entry <ReportRole>
                        (
                role
                        );

            entry.State = EntityState.Modified;
        }
コード例 #3
0
        public ActionResult Execute(ReportRole model, string action)
        {
            KeyValuePair <int, string> results = new KeyValuePair <int, string>(1, "");
            string message = Resources.ReportRole.ReportRoleSuccess;

            if (action == "Create")
            {
                if (db.reportRole.Where(x => x.SecurityRoleId == model.SecurityRoleId).Where(x => x.ReportID == model.ReportID).Count() > 0)
                {
                    var jsonData = new { flag = false, Message = Resources.ReportRole.ReportRoleSame };
                    return(Json(jsonData));
                }
            }

            if (action == "Delete")
            {
                message = Resources.NotifResource.PrivilegeExceptionDelSuccess;
            }

            switch (action)
            {
            case "Delete":
                results = db.ReportRole_Delete(model);
                break;

            case "Create":
                model.ReportRoleID = Guid.NewGuid();
                model.ModifiedBy   = new Guid(Session["CurrentUserID"].ToString());
                results            = db.ReportRole_Insert(model);
                break;
            }

            if (results.Key == 0 || results.Key == 16 || results.Key == 6)
            {
                var jsonData = new { flag = true, Message = message };
                return(Json(jsonData));
            }
            else
            {
                var jsonData = new { flag = false, Message = results.Value.ToString() };
                return(Json(jsonData));
            }
        }
コード例 #4
0
        public KeyValuePair <int, String> ReportRole_Delete(ReportRole model)
        {
            var param = new SqlParameter[] {
                new SqlParameter("@ReportRoleID", SqlDbType.UniqueIdentifier)
                {
                    Value = model.ReportRoleID
                },
                new SqlParameter("@RetVal", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                },
                new SqlParameter("@Message", SqlDbType.NVarChar, 100)
                {
                    Direction = ParameterDirection.Output
                }
            };

            int rc = ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreCommand("exec [CRM].[ReportRole_Delete] @ReportRoleID, @RetVal OUTPUT, @Message OUTPUT", param);

            int    retVal   = (int)param[1].Value;
            string valueRes = param[2].Value.ToString();

            return(new KeyValuePair <int, string>(retVal, valueRes));
        }