Exemplo n.º 1
0
        public ActionResult <List <Object> > GetDairy(long diaryId)
        {
            List <Object> result = new List <object>();
            var           diary  = _diaryService.GetById(diaryId);

            if (diary != null)
            {
                result.Add(diary);
                if (diary.TravelId != null)
                {
                    var travel = _travelService.GetById(diary.TravelId);
                    if (travel != null)
                    {
                        result.Add(travel);
                        var routes = _routeService.GetByTravelIdOrderStartTime(travel.TravelId);
                        foreach (Route r in routes)
                        {
                            var startSite = _siteService.GetById(r.StartSiteId);
                            var endSite   = _siteService.GetById(r.EndSiteId);
                            result.Add(r);
                            result.Add(startSite);
                            result.Add(endSite);
                        }
                    }
                }
                return(result);
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 2
0
 public ActionResult DeleteTravel(long travelId)
 {
     try
     {
         var travel = _travelService.GetById(travelId);
         if (travel != null)
         {
             _travelService.Delete(travel);
         }
     }
     catch (Exception e)
     {
         return(BadRequest(e.InnerException.Message));
     }
     return(NoContent());
 }
Exemplo n.º 3
0
        public IHttpActionResult GetTravelById(int id)
        {
            var travel = TravelService.GetById(id);

            return(Results(travel));
        }