public HttpResponseMessage putItemPrice(String id, Entities.MstItemPrice itemPrice) { try { var itemPrices = from d in db.MstItemPrices where d.Id == Convert.ToInt32(id) select d; if (itemPrices.Any()) { var updateItemPrice = itemPrices.FirstOrDefault(); updateItemPrice.ItemId = itemPrice.ItemId; updateItemPrice.PriceDescription = itemPrice.PriceDescription; updateItemPrice.Price = itemPrice.Price; updateItemPrice.TriggerQuantity = itemPrice.TriggerQuantity; db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound)); } } catch (Exception e) { // Debug.WriteLine(e); return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public HttpResponseMessage postItemPrice(Entities.MstItemPrice itemPrice) { try { Data.MstItemPrice newItemPrice = new Data.MstItemPrice(); newItemPrice.ItemId = itemPrice.ItemId; newItemPrice.PriceDescription = itemPrice.PriceDescription; newItemPrice.Price = itemPrice.Price; newItemPrice.TriggerQuantity = itemPrice.TriggerQuantity; db.MstItemPrices.InsertOnSubmit(newItemPrice); db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { Debug.WriteLine(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Something's wrong from the server.")); } }