Created
February 1, 2016 19:18
-
-
Save esmyth01/63b30c2f583e1c794aad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.Serialization; | |
using System.ServiceModel; | |
using System.Text; | |
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IShowTrackerService" in both code and config file together. | |
[ServiceContract] | |
public interface IShowTrackerService | |
{ | |
[OperationContract] | |
List<string> GetShows(); | |
[OperationContract] | |
List<string> GetArtists(); | |
[OperationContract] | |
List<string> GetVenues(); | |
[OperationContract] | |
List<ShowLite> ShowDetails(string artist); | |
[OperationContract] | |
List<ShowLite> VenueDetails(string venue); | |
} | |
[DataContract] | |
public class ShowLite | |
{ | |
[DataMember] | |
public string ShowName { set; get; } | |
[DataMember] | |
public string ShowTime { set; get; } | |
[DataMember] | |
public string ShowDate { set; get; } | |
[DataMember] | |
public string ShowTicketInfo { set; get; } | |
[DataMember] | |
public string VenueName { set; get; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.Serialization; | |
using System.ServiceModel; | |
using System.Text; | |
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ShowTrackerService" in code, svc and config file together. | |
public class ShowTrackerService : IShowTrackerService | |
{ | |
ShowTrackerEntities st = new ShowTrackerEntities(); | |
public List<string> GetArtists() | |
{ | |
var art = from a in st.Artists | |
orderby a.ArtistName | |
select new { a.ArtistName }; | |
List<string> artitsts = new List<string>(); | |
foreach (var ar in art) | |
{ | |
artitsts.Add(ar.ArtistName.ToString()); | |
} | |
return artitsts; | |
} | |
public List<string> GetShows() | |
{ | |
var shw = from sh in st.Shows | |
orderby sh.ShowName | |
select new { sh.ShowName }; | |
List<string> shows = new List<string>(); | |
foreach (var sh in shw) | |
{ | |
shows.Add(sh.ShowName.ToString()); | |
} | |
return shows; | |
} | |
public List<string> GetVenues() | |
{ | |
var ven = from ve in st.Venues | |
orderby ve.VenueName | |
select new { ve.VenueName }; | |
List<string> venues = new List<string>(); | |
foreach (var ve in ven) | |
{ | |
venues.Add(ve.VenueName.ToString()); | |
} | |
return venues; | |
} | |
public List<ShowLite> ShowDetails(string artist) | |
{ | |
var shws = from s in st.Shows | |
from sd in s.ShowDetails | |
where sd.Artist.ArtistName.Equals(artist) | |
select new { s.ShowName, s.ShowTime, s.ShowDate, s.Venue.VenueName, s.ShowTicketInfo }; | |
List<ShowLite> shows = new List<ShowLite>(); | |
foreach (var s in shws) | |
{ | |
ShowLite slite = new ShowLite(); | |
slite.ShowName = s.ShowName; | |
slite.ShowTime = s.ShowTime.ToString(); | |
slite.ShowDate = s.ShowDate.ToShortDateString(); | |
slite.ShowTicketInfo = s.ShowTicketInfo; | |
slite.VenueName = s.VenueName; | |
shows.Add(slite); | |
} | |
return shows; | |
} | |
public List<ShowLite> VenueDetails(string venue) | |
{ | |
var ven = from v in st.Shows | |
where v.Venue.VenueName.Equals(venue) | |
select new { v.ShowName, v.ShowTime, v.ShowDate, v.ShowTicketInfo, v.Venue.VenueName }; | |
List<ShowLite> shows = new List<ShowLite>(); | |
foreach (var v in ven) | |
{ | |
ShowLite slite = new ShowLite(); | |
slite.ShowName = v.ShowName; | |
slite.ShowTime = v.ShowTime.ToString(); | |
slite.ShowDate = v.ShowDate.ToShortDateString(); | |
slite.ShowTicketInfo = v.ShowTicketInfo; | |
slite.VenueName = v.VenueName; | |
shows.Add(slite); | |
} | |
return shows; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment