Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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());
            }
        }