protected static void AddRoleAction(int role_id, int scope_id, qPtl_User user) { var role_actions = qPtl_RoleAction.GetAvailableRoleActionsByRole(role_id, scope_id); DateTime startTime = DateTime.Now; DateTime endTime = DateTime.Now; foreach (var a in role_actions) { qPtl_UserAction action = new qPtl_UserAction(); qPtl_Action act = new qPtl_Action(a.ActionID); action.ScopeID = scope_id; action.Available = "Yes"; action.Created = DateTime.Now; action.CreatedBy = user.UserID; action.LastModified = DateTime.Now; action.LastModifiedBy = user.UserID; action.MarkAsDelete = 0; action.UserID = user.UserID; action.ActionID = a.ActionID; startTime = startTime.AddDays(a.StartDaysFromNow); endTime = endTime.AddDays(a.EndDaysFromNow); action.AvailableFrom = startTime; action.AvailableTo = endTime; action.AfterNumLogins = a.AfterNumLogins; action.Priority = a.Priority; action.SkipAllowed = a.SkipAllowed; action.NumberSkipsAllowed = a.NumberSkipsAllowed; action.Required = a.Required; action.OptionalOptOut = a.OptionOptOut; action.RedirectSkipURL = a.RedirectSkipURL; action.RedirectURL = a.RedirectURL; action.ReferenceID = act.ReferenceID; action.Insert(); } }
public static qPtl_Action GetActionByReferenceInfo(int content_type_id, int reference_id) { qPtl_Action action_item = new qPtl_Action(); action_item.container.Select(new DbQuery { Where = string.Format("ContentTypeID = {0} AND ReferenceID = {1} AND Available = 'Yes' AND MarkAsDelete = 0", content_type_id, reference_id) }); if (action_item.ActionID > 0) { return(action_item); } else { return(null); } }