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();
            }
        }
Ejemplo n.º 2
0
        // remote validations
        public ActionResult IsProjectValid(string ProjectCode)
        {
            var count  = _projectCodeService.GetProjectCodeId(ProjectCode);
            var result = (count > 0);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }