// POST api/itemexclusion/PostItemExclusion public HttpResponseMessage PostItemExclusion(API_ItemExclusion itemExclusion) { var rcMsg = Request.CreateResponse(HttpStatusCode.BadRequest); if ((ModelState.IsValid) && ((!string.IsNullOrEmpty(itemExclusion.ListSharePublicKey)) && (!string.IsNullOrEmpty(itemExclusion.ItemPublicKey)))) { try { using (var dataMethods = new DataMethods()) { var listShareID = dataMethods.ListShare_GetByPublicKey(itemExclusion.ListSharePublicKey).ListShareID; var itemID = dataMethods.ListItem_GetByPublicKey(itemExclusion.ItemPublicKey).ItemID; var rcItemExclusion = dataMethods.ItemExclusion_Create(listShareID, itemID); if (rcItemExclusion != null) { rcMsg = Request.CreateResponse(HttpStatusCode.Created, rcItemExclusion); } } } catch (Exception ex) { rcMsg = Request.CreateResponse(HttpStatusCode.BadRequest); } } else { rcMsg = Request.CreateResponse(HttpStatusCode.BadRequest); } return rcMsg; }
private static HttpResponseMessage CreateItemExclusion(API_ItemExclusion itemExclusion) { HttpResponseMessage response = client.PostAsJsonAsync("api/ItemExclusion/PostItemExclusion", itemExclusion).Result; if (!response.IsSuccessStatusCode) { throw new Exception("Error"); } return response; }
private static bool CreateItemExclusion_nonAPI(API_ItemExclusion itemExclusion) { var rc = false; using (DataMethods dataMethods = new DataMethods()) { var listShareID = dataMethods.ListShare_GetByPublicKey(itemExclusion.ListSharePublicKey).ListShareID; var itemID = dataMethods.ListItem_GetByPublicKey(itemExclusion.ItemPublicKey).ItemID; var newItemExclusion = dataMethods.ItemExclusion_Create(listShareID, itemID); if (newItemExclusion != null) { rc = true; } } return rc; }