public IHttpActionResult PostBuyerPriceTerm(BuyerPriceTermDetails buyerPriceTerm) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { if (buyerPriceTerm.BuyerPriceID != 0) { buyerPriceTerm.ModifiedBy = "superadmin"; buyerPriceTerm.ModifiedDate = DateTime.Now; db.BuyerPriceTerm.Attach(buyerPriceTerm); db.Entry(buyerPriceTerm).State = EntityState.Modified; } else { db.BuyerPriceTerm.Add(buyerPriceTerm); } db.SaveChanges(); return(Ok()); } catch (Exception e) { return(InternalServerError(e)); } }
public IHttpActionResult GetBuyerPriceTerm(Guid id) { BuyerPriceTermDetails buyerPriceTerm = db.BuyerPriceTerm.FirstOrDefault(x => x.BuyerId == id); if (buyerPriceTerm == null) { return(NotFound()); } return(Ok(buyerPriceTerm)); }