Exemplo n.º 1
0
 public ActionResult <Travel> AddTravel(Travel travel)
 {
     try
     {
         string date  = DateTime.Now.ToString("yyyyMMdd");
         var    query = _travelService.GetTravelByDate(date);
         if (query.Count() == 0)
         {
             travel.TravelId = System.Convert.ToInt64(date + "0000");
         }
         else
         {
             travel.TravelId = query.First().TravelId + 1;
         }
         _travelService.Add(travel);
     }
     catch (Exception e)
     {
         return(BadRequest(e.InnerException.Message));
     }
     return(NoContent());
 }