コード例 #1
0
        public async System.Threading.Tasks.Task <ActionResult> Delete(string tag)
        {
            HttpClient client = new HttpClient();

            var values = new Dictionary <string, string>
            {
                { "Tag", tag }
            };

            var content = new FormUrlEncodedContent(values);

            string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/";

            var response = await client.PostAsync(baseUrl + "api/Relations/RemovePact", content);

            return(View("Pacts", JsonConvert.DeserializeObject <List <Relation> >(JsonModels.GetJson((Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/") + "api/relations/byset/" + Startup.Storage.Reset))));
        }
コード例 #2
0
 public ActionResult AddPact(Relation relation)
 {
     if (relation.ValidateRelation())
     {
         Startup.Storage.Relations.Add(relation);
         Startup.Storage.newlyAddedRelations = true;
         if (Request.UrlReferrer.AbsolutePath == "/relations/New")
         {
             return(View("Pacts", JsonConvert.DeserializeObject <List <Relation> >(JsonModels.GetJson((Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/") + "api/relations/byset/" + Startup.Storage.Reset))));
         }
         else
         {
             return(Json(true, JsonRequestBehavior.DenyGet));
         }
     }
     if (Request.UrlReferrer.AbsolutePath == "/relations/New")
     {
         return(View("Pacts", JsonConvert.DeserializeObject <List <Relation> >(JsonModels.GetJson((Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/") + "api/relations/byset/" + Startup.Storage.Reset))));
     }
     else
     {
         return(Json(false, JsonRequestBehavior.DenyGet));
     }
 }
コード例 #3
0
 public ActionResult Pacts()
 {
     return(View(JsonConvert.DeserializeObject <List <Relation> >(JsonModels.GetJson((Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/") + "api/relations/byset/" + Startup.Storage.Reset))));
 }