internal BaseActionReturnModel AuthorizeApplicationtoClient(ClientApplication ClientApp,
                                                             ApplicationUser User,
                                                             SecurityDataContext ctx)
 {
     try
     {
         // Prevent double assignation
         if (ctx.UserAuthorizationAssignations.Count(p => p.ClientApplication.id == ClientApp.id &&
                                                     p.User.Id == User.Id) == 0)
         {
             UserClientAppAssignation r = new UserClientAppAssignation();
             r.User    = User;
             r.Blocked = false;
             r.App     = ClientApp;
             ctx.UserClientAppAssignations.Add(r);
             return(BaseActionReturnModel.CreateSuccededResult("OK", false, null, false));
         }
         else
         {
             return(BaseActionReturnModel.CreateSuccededResult("Application already assigned to client", false, null, true));
         }
     }
     catch (Exception exc)
     {
         return(BaseActionReturnModel.CreateException(exc, false));
     }
 }
예제 #2
0
        internal async Task <BaseActionReturnModel> SaveChangesAsync()
        {
            // create the delegate with the methode to run
            Func <BaseActionReturnModel> funcToRun = new Func <BaseActionReturnModel>(() => SaveChange());
            // run the delegate Async and return the Task result
            BaseActionReturnModel res = await Task.Factory.StartNew <BaseActionReturnModel>(funcToRun);

            return(res);
        }
예제 #3
0
 private BaseActionReturnModel SaveChange()
 {
     try
     {
         int i = ctx.SaveChanges();
         return(BaseActionReturnModel.CreateSuccededResult("OK " + i + " changes in database", false, null, false));
     }
     catch (Exception exc)
     {
         return(BaseActionReturnModel.CreateException(exc, false));
     }
 }
예제 #4
0
 internal BaseActionReturnModel AddClientApplication(ClientApplication App)
 {
     try
     {
         ctx.ClientApplications.Add(App);
         // do thing
         return(BaseActionReturnModel.CreateSuccededResult("OK", false, null, false));
     }
     catch (Exception exc)
     {
         return(BaseActionReturnModel.CreateException(exc, false));
     }
 }
예제 #5
0
 internal BaseActionReturnModel AddApplicationAuthorization(ApplicationAuthorization AdminAuth)
 {
     try
     {
         // do thing
         ctx.ApplicationAuthorizations.Add(AdminAuth);
         return(BaseActionReturnModel.CreateSuccededResult("OK", false, null, false));
     }
     catch (Exception exc)
     {
         return(BaseActionReturnModel.CreateException(exc, false));
     }
 }