Beispiel #1
0
        private void FillBranchIfItIsNecessary(ReviewTransport transport)
        {
            ReviewTransportBranch branch = transport.ReviewTransportBranch;

            if (String.IsNullOrEmpty(branch.Description))
            {
                TransportBranch existingBranch = this._transportService.GetTransportBranchById(transport.TransportId, branch.BranchId);
                branch.Description = existingBranch.Description;
            }

            this.FillOrientationIfItIsNecessary(transport);
        }
Beispiel #2
0
        public TransportBranchOrientation GetTransportBranchOrientationById(int transportId, int branchId, int orientationId)
        {
            TransportBranch            branch      = this.GetTransportBranchById(transportId, branchId);
            TransportBranchOrientation orientation = branch.Orientations.FirstOrDefault(x => x.OrientationId == orientationId);

            if (orientation == null)
            {
                throw new ObjectNotFoundException();
            }

            return(orientation);
        }
Beispiel #3
0
        public TransportBranch GetTransportBranchById(int transportId, int branchId)
        {
            if (this._branch == null)
            {
                this._branch = this._repository.GetFirstByConditions(x => x.TransportId == transportId && x.BranchId == branchId);

                if (this._branch == null)
                {
                    throw new ObjectNotFoundException();
                }
            }

            return(this._branch);
        }
Beispiel #4
0
        public ActionResult Get(int?transportId, int?branchId)
        {
            if (transportId.HasValue)
            {
                if (branchId.HasValue)
                {
                    TransportBranch transportBranch = this._transportService.GetTransportBranchById(transportId.Value, branchId.Value);

                    return(Ok(transportBranch));
                }
                else
                {
                    IList <TransportBranch> transportBranches;
                    transportBranches = this._transportService.GetTransportBranchByTransportId(transportId.Value);

                    return(Ok(transportBranches));
                }
            }
            else
            {
                return(BadRequest());
            }
        }