NightFlash : a Web API

* NFEvent.cs:
* Period.cs:
* OpenDay.cs:
* WeekDay.cs:
* Position.cs:
* Schedule.cs:
* Publishing.cs:
* Periodicity.cs:
* ProvidedEvent.cs:
* NightFlashController.cs:
* ProviderPublicInfo.cs:
* PositionAndKeyphrase.cs:
main
Paul Schneider 11 years ago
parent 629e80330d
commit cfd023411d
12 changed files with 697 additions and 0 deletions

@ -0,0 +1,80 @@
//
// NFEvent.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ApiControllers.NightFlash.Model
{
/// <summary>
/// NF event.
/// </summary>
public class NFEvent
{
/// <summary>
/// The title.
/// </summary>
[Required] public string Title { get; set; }
/// <summary>
/// The description.
/// </summary>
[Required] public string Description { get; set; }
/// <summary>
/// The type of the event.
/// </summary>
[Required] public string EventType { get; set; }
/// <summary>
/// The location.
/// </summary>
[Required] public Position Location { get; set; }
/// <summary>
/// The start date.
/// </summary>
[Required] public DateTime StartDate { get; set; }
/// <summary>
/// The name of the NF provider.
/// </summary>
[Required] public string NFProviderName { get; set; }
/// <summary>
/// The NF provider identifier.
/// </summary>
[Required] public string NFProviderId { get; set; }
/// <summary>
/// The type of the location.
/// </summary>
[Required] public string LocationType { get; set; }
/// <summary>
/// The promotion code.
/// </summary>
public string PromotionCode { get; set; }
/// <summary>
/// The event web page.
/// </summary>
public string EventWebPage { get; set; }
/// <summary>
/// The image locator.
/// </summary>
public string ImgLocator { get; set; }
}
}

@ -0,0 +1,56 @@
//
// OpenDay.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ApiControllers.NightFlash.Model
{
/// <summary>
/// Open day.
/// </summary>
public class OpenDay {
/// <summary>
/// The day.
/// </summary>
[Required]
public WeekDay Day;
public TimeSpan S { get; set; }
// ASSERT Start <= End
/// <summary>
/// Gets or sets the start hour.
/// </summary>
/// <value>The start.</value>
[Required]
public TimeSpan Start { get; set; }
/// <summary>
/// Gets or sets the end hour
/// (from the next day if lower than the Start).
/// </summary>
/// <value>The end.</value>
[Required]
public TimeSpan End { get; set; }
}
}

@ -0,0 +1,38 @@
//
// Period.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ApiControllers.NightFlash.Model
{
/// <summary>
/// Hollydays.
/// </summary>
public class Period {
[Required]
public DateTime Start { get; set; }
[Required]
public DateTime End { get; set; }
}
}

@ -0,0 +1,43 @@
//
// Periodicity.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ApiControllers.NightFlash.Model
{
/// <summary>
/// Periodicity.
/// </summary>
public enum Periodicity {
/// <summary>
/// The daily.
/// </summary>
Daily,
Weekly,
Monthly,
ThreeM,
SixM,
Yearly
}
}

@ -0,0 +1,43 @@
//
// Position.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ApiControllers.NightFlash.Model
{
/// <summary>
/// Position.
/// </summary>
public class Position
{
/// <summary>
/// The longitude.
/// </summary>
public double Longitude { get; set; }
/// <summary>
/// The latitude.
/// </summary>
public double Latitude { get; set; }
}
}

@ -0,0 +1,42 @@
//
// PositionAndKeyphrase.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ApiControllers.NightFlash.Model
{
/// <summary>
/// Position and keyphrase.
/// </summary>
public class PositionAndKeyphrase {
/// <summary>
/// The phrase.
/// </summary>
public string phrase;
/// <summary>
/// The position.
/// </summary>
public Position pos;
}
}

@ -0,0 +1,40 @@
//
// ProvidedEvent.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ApiControllers.NightFlash.Model
{
/// <summary>
/// Provided event.
/// </summary>
public class ProvidedEvent : NFEvent {
/// <summary>
/// The privacy.
/// </summary>
[Required]
public Publishing Privacy;
}
}

@ -0,0 +1,73 @@
//
// ProviderPublicInfo.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ApiControllers.NightFlash.Model
{
/// <summary>
/// Provider public info.
/// </summary>
public class ProviderPublicInfo {
/// <summary>
/// Gets or sets the display name.
/// </summary>
/// <value>The display name.</value>
[Required]
public string DisplayName { get; set; }
/// <summary>
/// Gets or sets the type of the location.
/// </summary>
/// <value>The type of the location.</value>
[Required]
public string LocationType { get; set; }
/// <summary>
/// Gets or sets the location.
/// </summary>
/// <value>The location.</value>
[Required]
public Position Location { get; set; }
/// <summary>
/// Gets or sets the logo image locator.
/// </summary>
/// <value>The logo image locator.</value>
public string LogoImgLocator { get; set; }
/// <summary>
/// Gets or sets the description.
/// </summary>
/// <value>The description.</value>
[Required]
public string Description { get; set;}
/// <summary>
/// Gets or sets the web page.
/// </summary>
/// <value>The web page.</value>
public string WebPage { get; set; }
/// <summary>
/// Gets or sets the calendar.
/// </summary>
/// <value>The calendar.</value>
public Schedule Calendar { get; set; }
}
}

@ -0,0 +1,43 @@
//
// Publishing.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ApiControllers.NightFlash.Model
{
/// <summary>
/// Publishing.
/// </summary>
public enum Publishing {
/// <summary>
/// The private.
/// </summary>
Private,
/// <summary>
/// The public.
/// </summary>
Public
}
}

@ -0,0 +1,48 @@
//
// Schedule.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ApiControllers.NightFlash.Model
{
/// <summary>
/// Schedule.
/// </summary>
public class Schedule {
public Periodicity Period { get; set; }
/// <summary>
/// Gets or sets the schedule of an open week.
/// One item by bay in the week,
/// </summary>
/// <value>The weekly workdays.</value>
public OpenDay [] WeekDays { get; set; }
/// <summary>
/// Gets or sets the hollydays.
/// </summary>
/// <value>The hollydays.</value>
[Required]
public Period [] Validity { get; set; }
}
}

@ -0,0 +1,62 @@
//
// WeekDay.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ApiControllers.NightFlash.Model
{
/// <summary>
/// Week day.
/// </summary>
public enum WeekDay:int {
/// <summary>
/// The monday (0).
/// </summary>
Monday=0,
/// <summary>
/// The tuesday.
/// </summary>
Tuesday,
/// <summary>
/// The wednesday.
/// </summary>
Wednesday,
/// <summary>
/// The thursday.
/// </summary>
Thursday,
/// <summary>
/// The friday.
/// </summary>
Friday,
/// <summary>
/// The saturday.
/// </summary>
Saturday,
/// <summary>
/// The sunday.
/// </summary>
Sunday
}
}

@ -0,0 +1,129 @@
//
// NightFlashController.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Web.Http;
using System.ComponentModel.DataAnnotations;
using Yavsc.ApiControllers.NightFlash.Model;
namespace Yavsc.ApiControllers.NightFlash
{
/// <summary>
/// Night flash controller.
/// </summary>
public class NightFlashController: ApiController
{
/// <summary>
/// List events according the specified search arguments.
/// </summary>
/// <param name="args">Arguments.</param>
[ValidateAjaxAttribute]
[HttpGet]
public NFEvent[] List ([FromUri] PositionAndKeyphrase args)
{
return new NFEvent[] {
new NFEvent () {
Title = "Test",
Description = "Test Descr",
EventType = "Night club special bubble party",
Location = new Position() {
Longitude = 0,
Latitude = 0
}
},
new NFEvent () {
Title = "Test2",
ImgLocator = "http://bla/im.png",
Location = new Position() {
Longitude = 0,
Latitude = 0
}
},
new NFEvent () {
Title = "Test",
Description = "Test Descr",
EventType = "Night club special bubble party",
Location = new Position() {
Longitude = 0,
Latitude = 0
}
},
new NFEvent () {
Title = "Test2",
ImgLocator = "http://bla/im.png",
Location = new Position() {
Longitude = 0,
Latitude = 0
}
}
};
}
/// <summary>
/// Provider the specified ProviderId.
/// </summary>
/// <param name="ProviderId">Provider identifier.</param>
[HttpGet]
public ProviderPublicInfo Provider ([FromUri] string ProviderId)
{
return new ProviderPublicInfo () {
DisplayName = "Yavsc clubing",
WebPage = "http://yavsc.pschneider.fr/",
Calendar = new Schedule () {
Period = Periodicity.ThreeM,
WeekDays = new OpenDay[] { new OpenDay () { Day = WeekDay.Saturday,
Start = new TimeSpan(18,00,00),
End = new TimeSpan(2,00,00)
} },
Validity = new Period[] { new Period() {
Start = new DateTime(2015,5,29),
End = new DateTime(2015,5,30)} }
},
Description = "Yavsc Entertainment Production, Yet another private party",
LogoImgLocator = "http://yavsc.pschneider.fr/favicon.png",
Location = new Position () { Longitude = 0, Latitude = 0 },
LocationType = "Salle des fêtes"
};
}
/// <summary>
/// Posts the image.
/// </summary>
/// <returns>The image.</returns>
/// <param name="NFProvId">NF prov identifier.</param>
public string PostImage([FromUri] string NFProvId)
{
return null;
}
/// <summary>
/// Posts the event.
/// </summary>
/// <returns>The event identifier.</returns>
/// <param name="ev">Ev.</param>
public int PostEvent ([FromBody] ProvidedEvent ev)
{
return -1;
}
}
}
Loading…