public bool Insert(RentedCar car)
 {
     try
     {
         using (var u = new RentedCarBusiness())
         {
             return(u.Insert(car));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(false);
     }
 }
 public RentedCar[] GetAll()
 {
     try
     {
         using (var c = new RentedCarBusiness())
         {
             return(c.GetAll().ToArray());
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(null);
     }
 }
Example #3
0
 public IHttpActionResult Put([FromBody] RentedCar car)
 {
     try
     {
         using (var c = new RentedCarBusiness())
         {
             if (c.Update(car))
             {
                 return(Ok());
             }
             return(NotFound());
         }
     }
     catch (Exception ex)
     {
         return(BadRequest($"{ex}"));
     }
 }
Example #4
0
 public IHttpActionResult Get(int id)
 {
     try
     {
         using (var c = new RentedCarBusiness())
         {
             var temp = c.GetAll().Where(s => s.Id == id).FirstOrDefault();
             if (temp == null)
             {
                 return(NotFound());
             }
             return(Ok(temp));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest($"{ex}"));
     }
 }
Example #5
0
 public IHttpActionResult Get()
 {
     try
     {
         using (var c = new RentedCarBusiness())
         {
             var templist = c.GetAll().ToList();
             if (templist == null)
             {
                 return(NotFound());
             }
             return(Ok(templist));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest($"{ex}"));
     }
 }