public void ReserveAd(string id) { try { var user = GetServiceUserEmail(); AdControl.GetInstance().ReserveAd(id, user); } catch (AlreadyReservedException ex) { throw new WebFaultException <AlreadyReservedException>(ex, HttpStatusCode.Forbidden); } catch (NotEnoughReservationsException ex) { throw new WebFaultException <NotEnoughReservationsException>(ex, HttpStatusCode.Forbidden); } catch (PostNotFoundException ex) { throw new WebFaultException <PostNotFoundException>(ex, HttpStatusCode.Forbidden); } catch (UserNotFoundException ex) { throw new WebFaultException <UserNotFoundException>(ex, HttpStatusCode.Forbidden); } catch (Exception ex) { throw new WebFaultException <Exception>(ex, HttpStatusCode.InternalServerError); } }
public void EditAd(string id, string title, string content, string locationName, AdType type) { try { AdControl.GetInstance().UpdateAd(GetServiceUserEmail(), id, title, content, locationName, type); } catch (InvalidOperationException) { throw new WebFaultException <string>("Can not edit other people's ads", HttpStatusCode.Unauthorized); } }
public void PostAd(string title, string content, string location, AdType type = AdType.Other) { try { var author = GetServiceUserEmail(); AdControl.GetInstance().PostAd(author, title, content, location, type); } catch (InvalidOperationException ex) { throw new WebFaultException <InvalidOperationException> (new InvalidOperationException("The post details were invalid. " + ex.Message), HttpStatusCode.BadRequest); } catch (UserNotFoundException) { throw new WebFaultException <UserNotFoundException>( new UserNotFoundException("The post author was not found."), HttpStatusCode.Unauthorized); } catch (LocationNotFoundException) { throw new WebFaultException <LocationNotFoundException> (new LocationNotFoundException("The post location was not found."), HttpStatusCode.NotFound); } }
public void UnreserveAd(string id) { try { var user = GetServiceUserEmail(); AdControl.GetInstance().UnreserveAd(id, user); } catch (ArgumentException ex) { throw new WebFaultException <ArgumentException>(ex, HttpStatusCode.Forbidden); } catch (PostNotFoundException ex) { throw new WebFaultException <PostNotFoundException>(ex, HttpStatusCode.Forbidden); } catch (UserNotFoundException ex) { throw new WebFaultException <UserNotFoundException>(ex, HttpStatusCode.Forbidden); } catch (Exception ex) { throw new WebFaultException <Exception>(ex, HttpStatusCode.InternalServerError); } }
public void GetPossibleLocationsTest() { var list = AdControl.GetInstance().GetPossibleLocationNames("Denmark"); Assert.IsTrue(list.Count > 1); }
public IList <Ad> FetchAds(int skip, int amount) { return(AdControl.GetInstance().GetAds(skip, amount)); }
public void DeleteAd(string id) { AdControl.GetInstance().DeleteAd(id, GetServiceUserEmail()); }
public IList <Ad> GetReservedAds() { return(AdControl.GetInstance().GetReservedAds(GetServiceUserEmail())); }
public IList <Ad> GetReservedAds(string userEmail) { return(AdControl.GetInstance().GetReservedAds(userEmail)); }
public Ad GetAd(string id) { return(AdControl.GetInstance().GetAd(id)); }
public IList <Comment> GetAdReplies(int skip, int amount, string adId) { return(AdControl.GetInstance().GetComments(skip, amount, adId)); }
public IList <Ad> FindAds(int skip, int amount, string location, string searchQuery, AdType adType = AdType.All) { return(AdControl.GetInstance().FindAds(skip, amount, location, searchQuery, adType)); }
public IList <Ad> GetAdsWithinLocation(int skip, int amount, string location) { return(AdControl.GetInstance().GetAdsWithinLocation(skip, amount, location)); }