Пример #1
0
 // Create
 public int Create(SALE_OFFER saleOfferModel)
 {
     saleOfferModel.Is_Deleted = false;
     db.SALE_OFFER.Add(saleOfferModel);
     db.SaveChanges();
     return(saleOfferModel.Id_SaleOffer);
 }
Пример #2
0
        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);
        }
Пример #3
0
        // 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);
            }
        }