public bool DeleteOtherDispatchAllocation(OtherDispatchAllocation otherDispatchAllocation)
 {
     if (otherDispatchAllocation == null) return false;
     _unitOfWork.OtherDispatchAllocationRepository.Delete(otherDispatchAllocation);
     _unitOfWork.Save();
     return true;
 }
        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();
            }
        }
 public bool DeleteOtherDispatchAllocation(OtherDispatchAllocation otherDispatchAllocation)
 {
     if (otherDispatchAllocation == null)
     {
         return(false);
     }
     _unitOfWork.OtherDispatchAllocationRepository.Delete(otherDispatchAllocation);
     _unitOfWork.Save();
     return(true);
 }
 public bool EditOtherDispatchAllocation(OtherDispatchAllocation otherDispatchAllocation)
 {
     _unitOfWork.OtherDispatchAllocationRepository.Edit(otherDispatchAllocation);
     _unitOfWork.Save();
     return true;
 }
        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);

            }
            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();

            }
        }
 public bool EditOtherDispatchAllocation(OtherDispatchAllocation otherDispatchAllocation)
 {
     _unitOfWork.OtherDispatchAllocationRepository.Edit(otherDispatchAllocation);
     _unitOfWork.Save();
     return(true);
 }