Beispiel #1
0
 public JsonResult ConfirmValidModel([FromBody] UploadModelJson model)
 {
     if (String.IsNullOrEmpty(model.model_license_id) ||
         String.IsNullOrEmpty(model.name) ||
         model.tags.Count == 0 ||
         String.IsNullOrEmpty(model.description))
     {
         //Failed the validation
         JsonResult res = Json(new { result = "Failure", reason = "Model does not contain all the proper inforation" });
         res.StatusCode = 406;
         return(res);
     }
     else
     {
         ObjectModel objectModel = new ObjectModel()
         {
             ModelLicenseId        = Guid.Parse(model.model_license_id),
             Name                  = model.name,
             PricingUnitOfMeaureId = model.pricing_unit_of_measure_id,
             TokenPrice            = model.token_price
         };
         objectModel.ObjectTags = "";
         foreach (var tag in model.tags)
         {
             objectModel.ObjectTags += tag + ";";
         }
         ObjectModel mod = null;
         try { mod = _ObjectModelService.Add(objectModel, User); } catch { return(Json(new { result = "Failure", reason = "Database Save Issue." })); }
         return(Json(new { result = "Success", file_id = mod.IdObjectModel }));
     }
 }
Beispiel #2
0
        public JsonResult Index()
        {
            UploadModelJson model = new UploadModelJson()
            {
                description = "Container", model_license_id = "40C03B2D-370D-45B9-9BCC-015DB1FF90B6", name = "Bottle Container", pricing_unit_of_measure_id = "USD", tags = new List <string>()
                {
                    "Bottle", "Container", "4 Pack", "Pack", "Beer", "Holder"
                }, token_price = .10m
            };

            return(Json(model));
        }