Ejemplo n.º 1
0
 public IActionResult LockApplication([FromHeader(Name = "Authorization")] string authString, [ModelBinder(Name = "id")] Application application)
 {
     if (ValidateRequest(Request, RequestValidationType.CredentialsOwnerAndIP, application))
     {
         var app = _context.Applications.Find(application.ID);
         app.Locked = true;
         _context.SaveChanges();
         WebsocketsIOC.TriggerApplicationLockedChanged(application.ID, true, 0);
         return(Created(new Uri("api/LockApplication", UriKind.Relative), application.ID));
     }
     return(Unauthorized());
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> UnlockApplication([FromHeader(Name = "Authorization")] string authString, [ModelBinder(Name = "id")] Application application)
        {
            if (ValidateRequest(Request, RequestValidationType.CredentialsOwnerAndIP, application))
            {
                var app = _context.Applications.Find(application.ID);
                app.Locked     = false;
                app.LastUpdate = DateTime.Now;
                app.Size_Bytes = await _fileManager.GetSizeForAppAsync(application.ID);

                _context.SaveChanges();
                WebsocketsIOC.TriggerUpdateAvailable(application.ID);
                WebsocketsIOC.TriggerApplicationLockedChanged(application.ID, false, app.Size_Bytes);
                return(Created(new Uri("api/UnlockApplication", UriKind.Relative), application.ID));
            }
            return(Unauthorized());
        }