Ejemplo n.º 1
0
        private SLS_BuyerOrder ConvertOrder(SlsBuyerOrder model, int userId, string url)
        {
            var entity = model.BuyerOrderID == 0 ? new SLS_BuyerOrder() : (from b in _context.SLS_BuyerOrder.AsEnumerable()
                                                                           where b.BuyerOrderID == model.BuyerOrderID
                                                                           select b).FirstOrDefault();

            entity.BuyerOrderID         = model.BuyerOrderID;
            entity.BuyerOrderNo         = model.BuyerOrderNo ?? DalCommon.GetPreDefineNextCodeByUrl(url);
            entity.OrderNo              = model.OrderNo;
            entity.BuyerOrderDate       = model.BuyerOrderDate == null ? DateTime.Now : DalCommon.SetDate(model.BuyerOrderDate);
            entity.OrderFrom            = model.OrderFrom;
            entity.BuyerOrderCategory   = model.BuyerOrderCategory;
            entity.BuyerID              = model.BuyerID;
            entity.BuyerAddressID       = model.BuyerAddressID;
            entity.BuyerLocalAgentID    = model.BuyerLocalAgentID;
            entity.BuyerForeignAgentID  = model.BuyerForeignAgentID;
            entity.BuyerRef             = model.BuyerRef;
            entity.ExpectedShipmentDate = model.ExpectedShipmentDate == null ? DateTime.Now : DalCommon.SetDate(model.ExpectedShipmentDate);
            entity.RevisionNo           = model.RevisionNo;
            entity.RevisionDate         = DalCommon.SetDate(model.RevisionDate);
            entity.OrderCurrency        = model.OrderCurrency;
            entity.BuyerOrderStatus     = model.BuyerOrderStatus == null ? "OD" : DalCommon.ReverseOrderStatus(model.BuyerOrderStatus);
            entity.RecordStatus         = model.BuyerOrderID == 0
                ? "NCF"
                : _unit.SlsBuyerOrederRepository.GetByID(model.BuyerOrderID).RecordStatus;
            entity.SetOn = model.BuyerOrderID == 0
                ? DateTime.Now
                : _unit.SlsBuyerOrederRepository.GetByID(model.BuyerOrderID).SetOn;
            entity.SetBy = model.BuyerOrderID == 0
                ? userId
                : _unit.SlsBuyerOrederRepository.GetByID(model.BuyerOrderID).SetBy;
            entity.ModifiedBy    = model.BuyerOrderID == 0 ? (int?)null : userId;
            entity.ModifiedOn    = model.BuyerOrderID == 0 ? (DateTime?)null : DateTime.Now;
            entity.OrderCurrency = model.OrderCurrency;
            entity.TotalFootQty  = model.TotalFootQty;
            entity.TotalMeterQty = model.TotalMeterQty;
            entity.PriceLevel    = model.PriceLevel;
            return(entity);
        }