Exemplo n.º 1
0
        public IHttpActionResult Delete(string Pid)
        {
            using (var ctx = new FSDEntities())
            {
                if (Pid.Length <= 0)
                {
                    return(BadRequest("Not a valid PO Order id"));
                }

                var orderdetails = ctx.PODETAILs.Where(s => s.PONO.Equals(Pid)).FirstOrDefault <PODETAIL>();
                if (orderdetails != null)
                {
                    ctx.Entry(orderdetails).State = System.Data.Entity.EntityState.Deleted;
                    ctx.SaveChanges();
                }
                var orderPo = ctx.POMASTERs.Where(s => s.PONO.Equals(Pid)).FirstOrDefault <POMASTER>();
                if (orderPo != null)
                {
                    ctx.Entry(orderPo).State = System.Data.Entity.EntityState.Deleted;
                    ctx.SaveChanges();
                }
            }
            return(Ok());
        }