public string AddArticle(BEArticle art) { string res = string.Empty; res = BLLArticle.addArticle(art); return(res); }
public bool addArticle(BEArticle art) { bool res = false; bdshoesEntities dc; articles nuevo = new articles { id = art.id, name = art.name, description = art.description, price = art.price, store_id = art.store_id, total_in_shelf = art.total_in_shelf, total_in_vault = art.total_in_vault, }; using (dc = new bdshoesEntities()) { dc.articles.Add(nuevo); dc.SaveChanges(); art.id = nuevo.id; res = art.id > 0; } return(res); }
public BERespuesta AddArticle(string name, string description, decimal price, int totalInShelf, int totalInVault, short storeId) { BEArticle nuevo = new BEArticle { id = 0, name = name, description = description, price = price, store_id = storeId, total_in_shelf = totalInShelf, total_in_vault = totalInVault, }; string returnMessage = string.Empty; BERespuesta res = new BERespuesta(); using (var client = new HttpClient()) { client.DefaultRequestHeaders.Clear(); client.BaseAddress = new Uri(baseApi); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); string inputJson = JsonConvert.SerializeObject(nuevo); HttpResponseMessage response = client.PostAsync("/services/articles/add", new StringContent(inputJson, Encoding.UTF8, "application/json")).Result; string jsonResult = response.Content.ReadAsStringAsync().Result; object objeto = JsonConvert.DeserializeObject(jsonResult); res = JsonConvert.DeserializeObject <BERespuesta>(objeto.ToString()); } return(res); }
public static string addArticle(BEArticle art) { string res = string.Empty; GenerateResponse gen = new GenerateResponse(); try { bool exito = dal.addArticle(art); res = gen.ResponseSuccess(); } catch (Exception ex) { res = gen.ResponseError(404, ex.Message); } return(res); }