public HttpResponseMessage putDiscountItem(String id, Entities.MstDiscountItem discountItem)
        {
            try
            {
                var discountItems = from d in db.MstDiscountItems where d.Id == Convert.ToInt32(id) select d;
                if (discountItems.Any())
                {
                    var updateDiscountItem = discountItems.FirstOrDefault();
                    updateDiscountItem.ItemId     = discountItem.ItemId;
                    updateDiscountItem.DiscountId = discountItem.DiscountId;
                    db.SubmitChanges();

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
            }
            catch (Exception e)
            {
                // Debug.WriteLine(e);
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage addDiscountItem(Entities.MstDiscountItem discountItem)
        {
            try
            {
                Data.MstDiscountItem newDiscountItems = new Data.MstDiscountItem();


                newDiscountItems.ItemId     = discountItem.ItemId;
                newDiscountItems.DiscountId = discountItem.DiscountId;
                db.MstDiscountItems.InsertOnSubmit(newDiscountItems);
                db.SubmitChanges();

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }