// Create public int Create(SALE_OFFER saleOfferModel) { saleOfferModel.Is_Deleted = false; db.SALE_OFFER.Add(saleOfferModel); db.SaveChanges(); return(saleOfferModel.Id_SaleOffer); }
public int Insert(SaleOfferDTO model) { SALE_OFFER saleModel = new SALE_OFFER(); saleModel.Date_SaleOffer = DateTime.Now; saleModel.Can_Bargain = model.canBargain; saleModel.Id_Farm = model.farmId; saleModel.Id_ProductDetail = model.productDetailId; saleModel.Quantity_SaleOffer = model.quantity; saleModel.Id_MassUnit = model.idUnit; saleModel.Price_Offer = model.price; saleModel.Paying_Time = model.payingTime; saleModel.Delivering_Time = model.deliveringTime; //db.SALE_OFFER.Add(saleOffer); db.SaveChanges(); return(1); }
// Update public bool Update(SALE_OFFER saleOfferModel) { var targetUpdate = db.SALE_OFFER.Find(saleOfferModel.Id_SaleOffer); try { targetUpdate.Id_Farm = saleOfferModel.Id_Farm; targetUpdate.Id_MassUnit = saleOfferModel.Id_MassUnit; targetUpdate.Id_ProductDetail = saleOfferModel.Id_ProductDetail; targetUpdate.Date_SaleOffer = saleOfferModel.Date_SaleOffer; targetUpdate.Price_Offer = saleOfferModel.Price_Offer; targetUpdate.Quantity_SaleOffer = saleOfferModel.Quantity_SaleOffer; targetUpdate.Remain_SaleQuantity = saleOfferModel.Remain_SaleQuantity; db.SaveChanges(); return(true); } catch (Exception e) { return(false); throw new Exception(e.Message); } }