示例#1
0
        public IEnumerable <ActionModel> LoadActions(string path, string partner)
        {
            var          json    = _fileProvider.Value.read(path);
            ActionsModel actions = null;

            try
            {
                actions = JsonConvert.DeserializeObject <ActionsModel>(json);
            }
            catch (Exception)
            {
                // log exception
                Console.WriteLine($"Failed to deserialize JSON for {partner}");
            }

            var list = new List <ActionModel>();

            if (actions?.revocations?.Any() == true)
            {
                list.AddRange(actions.revocations.Select(c => {
                    c.action  = "revocation";
                    c.partner = partner;
                    return(c);
                }));
            }
            if (actions?.grants?.Any() == true)
            {
                list.AddRange(actions.grants.Select(c => {
                    c.action  = "grant";
                    c.partner = partner;
                    return(c);
                }));
            }
            return(list);
        }
示例#2
0
        // GET: Actions
        public ActionResult Index()
        {
            var model = new ActionsModel
            {
                ListActions      = new Actions().GetAllHierachy2($"\xA0\xA0\xA0"),
                ListActionStatus = ActionStatus.Static_GetList()
            };

            return(View(model));
        }
示例#3
0
        public async Task AddLogAsync(string dbName, long id, string username, string type, string reason)
        {
            var mongoDbHandler = new MongoDBHandler(dbName);
            var actionModel    = new ActionsModel(type, reason);
            var currentEntry   = mongoDbHandler.LoadRecordByField <UserLogsModel>("Logs", "_id", id);
            var actions        = new List <ActionsModel>();

            if (currentEntry != null)
            {
                actions = currentEntry.Actions;
            }

            actions.Add(actionModel);

            var userLogsModel = new UserLogsModel(id, username, actions);

            await mongoDbHandler.Upsert("Logs", userLogsModel.UserId, userLogsModel);
        }
示例#4
0
 public ActionResult MultipleAction(ActionsModel model)
 {
     if (model.ActionsId != null && model.ActionsId.Length > 0)
     {
         short systemMessageId = 0;
         foreach (var actionId in model.ActionsId)
         {
             var action = new Actions
             {
                 ActionId = actionId
             };
             if (model.Delete != null)
             {
                 action.Delete(0, 0, ref systemMessageId);
             }
         }
     }
     return(Redirect("/Actions/Index"));
 }
示例#5
0
 public ActionsViewModel()
 {
     this.actionsModel = new ActionsModel();
 }