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); }
// GET: Actions public ActionResult Index() { var model = new ActionsModel { ListActions = new Actions().GetAllHierachy2($"\xA0\xA0\xA0"), ListActionStatus = ActionStatus.Static_GetList() }; return(View(model)); }
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); }
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")); }
public ActionsViewModel() { this.actionsModel = new ActionsModel(); }