public void Save(ViewModels.Dispatch.OtherDispatchAllocationViewModel model)
        {
            OtherDispatchAllocation oAllocation = new OtherDispatchAllocation();

            if (model.OtherDispatchAllocationID != null)
            {
                oAllocation = _unitOfWork.OtherDispatchAllocationRepository.FindById(int.Parse(model.OtherDispatchAllocationID.Value.ToString()));

                oAllocation.OtherDispatchAllocationID = model.OtherDispatchAllocationID.Value;
                oAllocation.ProgramID             = model.ProgramID.Value;
                oAllocation.HubID                 = model.FromHubID.Value;
                oAllocation.ToHubID               = model.ToHubID.Value;
                oAllocation.ReasonID              = model.ReasonID;
                oAllocation.ReferenceNumber       = model.ReferenceNumber;
                oAllocation.AgreementDate         = model.AgreementDate;
                oAllocation.CommodityID           = model.CommodityID;
                oAllocation.EstimatedDispatchDate = model.EstimatedDispatchDate;
                oAllocation.IsClosed              = model.IsClosed;
                oAllocation.ProjectCodeID         = _projectCodeService.GetProjectCodeId(model.ProjectCode);
                oAllocation.ShippingInstructionID =
                    _shippingInstructionService.GetShipingInstructionId(model.ShippingInstruction);
                oAllocation.UnitID         = model.UnitID;
                oAllocation.QuantityInUnit = model.QuantityInUnit;
                oAllocation.QuantityInMT   = model.QuantityInMT;
                oAllocation.QuantityInUnit = model.QuantityInUnit;
                oAllocation.Remark         = model.Remark;
                //Modify Banty :From SaveChanges(oAllocation) to SaveChanges()
                // repository.OtherDispatchAllocation.SaveChanges(oAllocation);
                _unitOfWork.Save();
            }
            else
            {
                oAllocation.PartitionID = (model.PartitionID.HasValue) ? model.PartitionID.Value : 0;
                if (model.OtherDispatchAllocationID.HasValue)
                {
                    oAllocation.OtherDispatchAllocationID = model.OtherDispatchAllocationID.Value;
                }
                oAllocation.ProgramID             = model.ProgramID.Value;
                oAllocation.HubID                 = model.FromHubID.Value;
                oAllocation.ToHubID               = model.ToHubID.Value;
                oAllocation.ReasonID              = model.ReasonID;
                oAllocation.ReferenceNumber       = model.ReferenceNumber;
                oAllocation.AgreementDate         = model.AgreementDate;
                oAllocation.CommodityID           = model.CommodityID;
                oAllocation.EstimatedDispatchDate = model.EstimatedDispatchDate;
                oAllocation.IsClosed              = model.IsClosed;
                oAllocation.ProjectCodeID         = _projectCodeService.GetProjectCodeId(model.ProjectCode);
                oAllocation.ShippingInstructionID =
                    _shippingInstructionService.GetShipingInstructionId(model.ShippingInstruction);
                oAllocation.UnitID         = model.UnitID;
                oAllocation.QuantityInUnit = model.QuantityInUnit;
                oAllocation.QuantityInMT   = model.QuantityInMT;
                oAllocation.QuantityInUnit = model.QuantityInUnit;
                oAllocation.Remark         = model.Remark;
                _unitOfWork.OtherDispatchAllocationRepository.Add(oAllocation);//
                _unitOfWork.Save();
            }
        }
示例#2
0
        public ActionResult IsSIValid(string ShippingInstruction)
        {
            bool result = false;

            result = _shippingInstructionService.GetShipingInstructionId(ShippingInstruction) > 0;
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#3
0
 private int CheckAvilabilityOfSiNumber(string siNumber)
 {
     try
     {
         var siId = _shippingInstructionService.GetShipingInstructionId(siNumber);
         return(siId);
     }
     catch (Exception)
     {
         return(0);
     }
 }
示例#4
0
        public ActionResult IsSIValid(string siNumber, int?fdpid)
        {
            bool result;

            if (fdpid != null)
            {
                result = _shippingInstructionService.HasBalance(siNumber, fdpid.Value);
            }
            else
            {
                result = _shippingInstructionService.GetShipingInstructionId(siNumber) > 0;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public List <ReceiptAllocation> GetUnclosedAllocationsDetached(int hubId, int commoditySoureType, bool?closedToo, string weightMeasurmentCode, int?CommodityType, bool?receivable)
        {
            List <ReceiptAllocation> GetDetachecedList = new List <ReceiptAllocation>();

            //var x = GetListOfSource(commoditySoureType);
            var receiptAll = _unitOfWork.ReceiptAllocationRepository.Get().ToList();
            var unclosed   = (from rAll in receiptAll
                              where hubId == rAll.HubID
                              select rAll).ToList();

            if (closedToo == null || closedToo == false)
            {
                unclosed = unclosed.Where(p => p.IsClosed == false).ToList();
            }
            else
            {
                unclosed = unclosed.Where(p => p.IsClosed == true).ToList();
            }

            if (receivable == null || receivable == false)
            {
                unclosed = unclosed.Where(p => p.IsFalseGRN == false).ToList();
            }
            else
            {
                unclosed = unclosed.Where(p => p.IsFalseGRN == true).ToList();
            }

            unclosed = CommodityType.HasValue ? unclosed.Where(p => p.Commodity.CommodityTypeID == CommodityType.Value).ToList() : unclosed.Where(p => p.Commodity.CommodityTypeID == 1).ToList();

            foreach (ReceiptAllocation receiptAllocation in unclosed)
            {
                // int si = _unitOfWork.ShippingInstructionRepository.Get(s=>s.ShippingInstructionID == receiptAllocation.si
                int si = _ShippingInstructionService.GetShipingInstructionId(receiptAllocation.SINumber);
                receiptAllocation.RemainingBalanceInMT = receiptAllocation.QuantityInMT -
                                                         GetReceivedAlready(
                    receiptAllocation);
                receiptAllocation.CommodityName = receiptAllocation.Commodity.Name;


                if (receiptAllocation.QuantityInUnit != null)
                {
                    receiptAllocation.RemainingBalanceInUnit = receiptAllocation.QuantityInUnit.Value -
                                                               GetReceivedAlreadyInUnit(receiptAllocation);
                }
                else
                {
                    receiptAllocation.RemainingBalanceInUnit = 0 -
                                                               GetReceivedAlreadyInUnit(receiptAllocation);
                }


                if (weightMeasurmentCode == "qn")
                {
                    receiptAllocation.QuantityInMT         *= 10;
                    receiptAllocation.RemainingBalanceInMT *= 10;
                    receiptAllocation.ReceivedQuantityInMT *= 10;
                }
                //modified Banty:24_5_2013 from db.Detach to ((IObjectContextAdapter)db).ObjectContext.Detach
                //   ((IObjectContextAdapter)db).ObjectContext.Detach(receiptAllocation);
                //Commented out by banty 16/8/2013
                GetDetachecedList.Add(receiptAllocation);
            }

            return(GetDetachecedList.ToList());
        }