public async Task <OperationResult> RunNoAuth(ContextModel model) { ConfigurationContext ctxt; switch (model.Type) { // Commands case ContextType.CreateEntry: ctxt = _model.CreateContext(model.Key, model.Value); return(await Factory.RunOperationAsync(ctxt)); case ContextType.UpdateEntry: ctxt = _model.UpdateContext(model.Key, model.Value); return(await Factory.RunOperationAsync(ctxt)); case ContextType.DeleteEntry: ctxt = _model.DeleteContext(model.Key); return(await Factory.RunOperationAsync(ctxt)); // Queries case ContextType.ReadEntry: ctxt = _model.QueryOne(model.Key); return(await Factory.RunOperationAsync(ctxt)); case ContextType.ReadAllEntries: ctxt = _model.QueryAll(model.Key); return(await Factory.RunOperationAsync(ctxt)); // Import / Export case ContextType.DownloadAsFile: return(await DownloadAs(model.Key)); case ContextType.UploadAFile: var result = await Upload(model.Value, model.Key); return(result); // User Operations case ContextType.AddUser: ctxt = _model.CreateUserContext(model.User, _authStorage, model.AppClaims); return(await Factory.RunOperationAsync(ctxt)); case ContextType.UpdateUser: ctxt = _model.UpdateUserContext(model.User, _authStorage, model.AppClaims); return(await Factory.RunOperationAsync(ctxt)); case ContextType.DeleteUser: ctxt = _model.DeleteUserContext(model.User, _authStorage); return(await Factory.RunOperationAsync(ctxt)); case ContextType.GetUser: ctxt = _model.ReadUserContext(model.User, _authStorage); return(await Factory.RunOperationAsync(ctxt)); default: throw new NotSupportedException($"model.contextType : [{model.Type.ToString()}] is not supported"); } }
public async Task <IActionResult> Login(AuthModelDto model, string from) { var authModel = new AuthModel(model.Name, model.Password); var context = _model.ReadUserContext(authModel, _authStorageModel); OperationResult result = await Factory.RunOperationAsync(context); if (result.IsSuccess) { string[] ab = from.Split('/'); return(RedirectToAction ( actionName: ab.Last(), controllerName: ab.First(), new { model.Name, model.Password } )); } else { return(RedirectToAction(nameof(Index))); } }