public JsonResult GetModels()
        {
            using (var db = new DropDB())
            {
                var models = db.models.ToList();

                string json = JsonConvert.SerializeObject(models);

                return Json(json, JsonRequestBehavior.AllowGet);
            }
        }
 private void ClearDatabase()
 {
     using (var db = new DropDB())
     {
         foreach (var model in db.models)
         {
             db.Entry(model).State = System.Data.EntityState.Deleted;
             db.SaveChanges();
         }
     }
 }
        public async Task UploadFiles(IEnumerable<HttpPostedFileBase> files)
        {
            foreach(var file in files)
            {
                var fi = FileUploadInfo.CreateFromStream(
                    file.FileName,
                    file.InputStream);

                var objDetailsResponse = await _viewDataClient.UploadFileAsync(
                    BUCKET_NAME,
                    fi);

                if(!objDetailsResponse.IsOk())
                {
                    continue;
                }

                var objDetails = objDetailsResponse.Objects[0];

                var bubbleResponse = await _viewDataClient.RegisterAsync(
                    objDetails.FileId);

                if (!bubbleResponse.IsOk())
                {
                    continue;
                }

                using (var db = new DropDB())
                {
                    var entry = new model();

                    entry.ModelId = objDetails.FileId.ToBase64();
                    entry.Name = objDetails.ObjectKey.Split(new char[]{'.'})[0];

                    db.models.Add(entry);
                    db.SaveChanges();

                    string url = "http://" + Request.Url.Authority + "/api/push/message";

                    PushMessage(url, new PushMessage(entry.Name, entry.ModelId));
                } 
            }
        }