//--------------------------------------------- public MainControllerModule() { Get["ReDoMeApi/GetSalon"] = parameters => { try { SendLogMessage("called ReDoMeApi/GetSalon", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.barber.HasValue) { throw new Exception("Missing parameter Barber"); } string barberVkId = this.Request.Query.barber; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); Salon salon = Database.getSalonByBarber(barberVkId); if (salon == null) { ErrorAnswer answer = new ErrorAnswer("salon not found"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(salon.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error GetSalon: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/GetSalon", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/GetSalonById"] = parameters => { try { SendLogMessage("called ReDoMeApi/GetSalonById", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.sal_id.HasValue) { throw new Exception("Missing parameter sal_id"); } int sal_ID = this.Request.Query.sal_id; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); Salon salon = Database.getSalonByID(sal_ID); if (salon == null) { ErrorAnswer answer = new ErrorAnswer("salon not found"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(salon.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error GetSalonById: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/GetSalonById", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/GetAllSalons"] = parameters => { try { SendLogMessage("called ReDoMeApi/GetAllSalons", System.Diagnostics.EventLogEntryType.SuccessAudit); //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); SalonList salonList = Database.getSalons(); if (salonList == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(salonList.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error GetAllSalons: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/GetAllSalons", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/GetSalonPortfolio"] = parameters => { try { SendLogMessage("called ReDoMeApi/GetSalonPortfolio", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.sal_id.HasValue) { throw new Exception("Missing parameter sal_id"); } int sal_ID = this.Request.Query.sal_id; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); PhotoList photos = Database.getSalonPhotos(sal_ID, PhotoType.PortfolioSalon); if (photos == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(photos.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error GetSalonPortfolio: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/GetSalonPortfolio", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/GetAllBarbers"] = parameters => { try { SendLogMessage("called ReDoMeApi/GetAllBarbers", System.Diagnostics.EventLogEntryType.SuccessAudit); BarberList barberList = Database.getBarbers(); if (barberList == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(barberList.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error GetAllBarbers: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/GetAllBarbers", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/GetBarber"] = parameters => { try { SendLogMessage("called ReDoMeApi/GetBarber", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.barber.HasValue) { throw new Exception("Missing parameter barber"); } string barber_vk_id = this.Request.Query.barber; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); Barber barber = Database.getBarber(barber_vk_id); if (barber == null) { ErrorAnswer answer = new ErrorAnswer("barber not found"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(barber.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error GetBarber: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/GetBarber", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/GetBarberPortfolio"] = parameters => { try { SendLogMessage("called ReDoMeApi/GetBarberPortfolio", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.barber.HasValue) { throw new Exception("Missing parameter barber"); } string barber_vk_id = this.Request.Query.barber; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); PhotoList photos = Database.getBarberPhotos(barber_vk_id, PhotoType.PortfolioMaster); if (photos == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(photos.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error GetBarberPortfolio: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/GetBarberPortfolio", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/getStarByFace"] = parameters => { try { SendLogMessage("called ReDoMeApi/getStarByFace", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.photo_link.HasValue) { throw new Exception("Missing parameter photo_link"); } string photo_link = this.Request.Query.photo_link; StarByFaceList faceList = StarByFaceClient.GetStarsList(photo_link); //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); //PhotoList photos = Database.getBarberPhotos(barber_vk_id, PhotoType.PortfolioMaster); //if (photos == null) //{ // ErrorAnswer answer = new ErrorAnswer("server error"); // return ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK); //} return(ReDoMeAPIResponse.CreateResponse(faceList.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error getStarByFace: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/getStarByFace", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; }
public RequestControllerModule() { Post["ReDoMeApi/Request/Create"] = parameters => { try { SendLogMessage("called ReDoMeApi/Request/Create", System.Diagnostics.EventLogEntryType.SuccessAudit); var jsonString = this.Request.Body.AsString(); Request request = ReDoMeAPI.Request.FromJson(jsonString); request.state = RequestState.New; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); Int64 Req_ID = Database.createRequest(request); if (Req_ID == 0) { ErrorAnswer answer = new ErrorAnswer("creating request error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(Req_ID.ToString(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Request/Create: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Request/Create", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Post["ReDoMeApi/Request/AddPhotos"] = parameters => { try { SendLogMessage("called ReDoMeApi/Request/AddPhotos", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.req_id.HasValue) { throw new Exception("Missing parameter req_id"); } Int64 Req_ID = this.Request.Query.req_id; var jsonString = this.Request.Body.AsString(); PhotoList photos = ReDoMeAPI.PhotoList.FromJson(jsonString); //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); if (!Database.addPhotosToRequest(Req_ID, photos)) { ErrorAnswer answer = new ErrorAnswer("adding photos error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse("OK", HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Request/AddPhotos: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Request/AddPhotos", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/Request/GetOffers"] = parameters => { try { SendLogMessage("called ReDoMeApi/Request/GetOffers", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.req_id.HasValue) { throw new Exception("Missing parameter req_id"); } int Req_ID = this.Request.Query.req_id; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); OfferList offers = Database.getOffersForRequest(Req_ID); if (offers == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(offers.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Request/GetOffers: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Request/GetOffers", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/Request/GetPhotos"] = parameters => { try { SendLogMessage("called ReDoMeApi/Request/GetPhotos", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.req_id.HasValue) { throw new Exception("Missing parameter req_id"); } int Req_ID = this.Request.Query.req_id; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); PhotoList photos = Database.getRequestPhotos(Req_ID); if (photos == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(photos.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Request/GetPhotos: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Request/GetPhotos", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/Request/SetScore"] = parameters => { try { SendLogMessage("called ReDoMeApi/Request/SetScore", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.req_id.HasValue) { throw new Exception("Missing parameter req_id"); } if (!this.Request.Query.score.HasValue) { throw new Exception("Missing parameter score"); } int Req_ID = this.Request.Query.req_id; int Score = this.Request.Query.score; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); if (!Database.setScoreForRequest(Req_ID, Score)) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse("OK", HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Request/SetScore: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Request/SetScore", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/Request/GetAllNew"] = parameters => { try { SendLogMessage("called ReDoMeApi/Request/GetAllNew", System.Diagnostics.EventLogEntryType.SuccessAudit); //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); RequestList requests = Database.getRequests(RequestState.New); if (requests == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(requests.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Request/GetAllNew: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Request/GetAllNew", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/Request/GetAll"] = parameters => { try { SendLogMessage("called ReDoMeApi/Request/GetAll", System.Diagnostics.EventLogEntryType.SuccessAudit); //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); RequestList requests = Database.getRequests(RequestState.Any); if (requests == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(requests.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Request/GetAll: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Request/GetAll", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/Request/GetByClient"] = parameters => { try { SendLogMessage("called ReDoMeApi/Request/GetByClient", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.client.HasValue) { throw new Exception("Missing parameter Client"); } string clientVkId = this.Request.Query.client; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); RequestList requests = Database.getRequestsByClient(clientVkId); if (requests == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(requests.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Request/GetByClient: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Request/GetByClient", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/Request/GetByBarber"] = parameters => { try { SendLogMessage("called ReDoMeApi/Request/GetByBarber", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.barber.HasValue) { throw new Exception("Missing parameter Barber"); } string barberVkId = this.Request.Query.barber; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); RequestList requests = Database.getRequestsByMaster(barberVkId); if (requests == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(requests.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Request/GetByBarber: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Request/GetByBarber", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; }
public OfferControllerModule() { Post["ReDoMeApi/Offer/Create"] = parameters => { try { SendLogMessage("called ReDoMeApi/Offer/Create", System.Diagnostics.EventLogEntryType.SuccessAudit); var jsonString = this.Request.Body.AsString(); Offer offer = ReDoMeAPI.Offer.FromJson(jsonString); offer.selected = false; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); Int64 Offer_ID = Database.createOffer(offer); if (Offer_ID == 0) { ErrorAnswer answer = new ErrorAnswer("creating offer error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(Offer_ID.ToString(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Offer/Create: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Offer/Create", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Post["ReDoMeApi/Offer/AddPhotos"] = parameters => { try { SendLogMessage("called ReDoMeApi/Offer/AddPhotos", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.offer_id.HasValue) { throw new Exception("Missing parameter offer_id"); } Int64 Offer_ID = this.Request.Query.offer_id; var jsonString = this.Request.Body.AsString(); PhotoList photos = ReDoMeAPI.PhotoList.FromJson(jsonString); //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); if (!Database.addPhotosToOffer(Offer_ID, photos)) { ErrorAnswer answer = new ErrorAnswer("adding photos error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse("OK", HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Offer/AddPhotos: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Offer/AddPhotos", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Put["ReDoMeApi/Offer/Accept"] = parameters => { try { SendLogMessage("called ReDoMeApi/Offer/Accept", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.offer_id.HasValue) { throw new Exception("Missing parameter offer_id"); } if (!this.Request.Query.req_id.HasValue) { throw new Exception("Missing parameter req_id"); } int Req_ID = this.Request.Query.req_id; int Offer_ID = this.Request.Query.offer_id; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); bool bRes = Database.acceptOffer(Req_ID, Offer_ID); if (!bRes) { ErrorAnswer answer = new ErrorAnswer("offer not found"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse("OK", HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Offer/Accept: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Offer/Accept", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/Offer/Delete"] = parameters => { try { SendLogMessage("called ReDoMeApi/Offer/Delete", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.offer_id.HasValue) { throw new Exception("Missing parameter offer_id"); } int Offer_ID = this.Request.Query.offer_id; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); if (!Database.deleteOffer(Offer_ID)) { ErrorAnswer answer = new ErrorAnswer("offer not found"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse("OK", HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Offer/Delete: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Offer/Delete", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/Offer/GetStatusesByBarber"] = parameters => { try { SendLogMessage("called ReDoMeApi/Offer/GetStatusesByBarber", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.barber.HasValue) { throw new Exception("Missing parameter Barber"); } string barberVkId = this.Request.Query.barber; RequestState state = RequestState.Any; if (this.Request.Query.state.HasValue) { state = (RequestState)((Int16)this.Request.Query.state); } //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); RequestWithOfferList offers = Database.getOffersState(barberVkId, state); if (offers == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(offers.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Offer/GetStatusesByBarber: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Offer/GetStatusesByBarber", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; Get["ReDoMeApi/Offer/GetPhotos"] = parameters => { try { SendLogMessage("called ReDoMeApi/Offer/GetPhotos", System.Diagnostics.EventLogEntryType.SuccessAudit); if (!this.Request.Query.offer_id.HasValue) { throw new Exception("Missing parameter offer_id"); } int Offer_ID = this.Request.Query.offer_id; //if (User != Tracking.Options.MainOptions.WEBAPIUser || Password != Tracking.Options.MainOptions.WEBAPIPassword) // throw new Exception("Invalid password or login"); PhotoList photos = Database.getOfferPhotos(Offer_ID); if (photos == null) { ErrorAnswer answer = new ErrorAnswer("server error"); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } return(ReDoMeAPIResponse.CreateResponse(photos.ToJson(), HttpStatusCode.OK)); } catch (Exception exc) { string Err = $"Error Offer/GetPhotos: {exc.Message}"; SendLogMessage(Err, System.Diagnostics.EventLogEntryType.Error); ErrorAnswer answer = new ErrorAnswer(exc.Message); return(ReDoMeAPIResponse.CreateResponse(answer.ToJson(), HttpStatusCode.OK)); } finally { SendLogMessage("ended ReDoMeApi/Offer/GetPhotos", System.Diagnostics.EventLogEntryType.SuccessAudit); } }; }