Ejemplo n.º 1
0
        public bool DeleteRequest(int id)
        {
            using (var context = new OneOffEntities())
            {
                var entity = context
                             .Requests
                             //  TODO: check ownership
                             .SingleOrDefault(e => e.RequestId == id);

                context.Requests.Remove(entity);
                return(context.SaveChanges() == 1);
            }
        }
Ejemplo n.º 2
0
        public bool UpdateRequest(int id, RequestUpdateResource request)
        {
            using (var context = new OneOffEntities())
            {
                var entity = context
                             .Requests
                             .SingleOrDefault(e => e.RequestId == id);

                entity.Date  = request.Date;
                entity.Offer = request.Offer;

                return(context.SaveChanges() == 1);
            }
        }
Ejemplo n.º 3
0
        public bool UpdateGig(int id, GigUpdateResource gig)
        {
            using (var context = new OneOffEntities())
            {
                var entity = context
                             .Gigs
                             .SingleOrDefault(e => e.GigId == id);

                entity.Date       = gig.Date;
                entity.PostalCode = gig.PostalCode;

                return(context.SaveChanges() == 1);
            }
        }
Ejemplo n.º 4
0
        public async Task <bool> CreateArtist(ArtistResource artist)
        {
            var entity =
                new Artist()
            {
                Name        = artist.Name,
                Description = artist.Description
            };

            using (var context = new OneOffEntities())
            {
                context.Artists.Add(entity);
                return(await context.SaveChangesAsync() == 1);
            }
        }
Ejemplo n.º 5
0
        public async Task <bool> CreateVenue(VenueResource venue)
        {
            var entity =
                new Venue()
            {
                Name        = venue.Name,
                Description = venue.Description,
                PostalCode  = venue.PostalCode
            };

            using (var ctx = new OneOffEntities())
            {
                ctx.Venues.Add(entity);
                return(await ctx.SaveChangesAsync() == 1);
            }
        }
Ejemplo n.º 6
0
        public RequestResource GetRequestById(int id)
        {
            using (var context = new OneOffEntities())
            {
                var entity = context
                             .Requests
                             //  TODO: check ownership
                             .SingleOrDefault(e => e.RequestId == id);

                return
                    (new RequestResource
                {
                    Date = entity.Date,
                    Offer = entity.Offer,
                    VenueId = entity.VenueId
                });
            }
        }
Ejemplo n.º 7
0
        public GigResource GetGigById(int id)
        {
            using (var context = new OneOffEntities())
            {
                var entity = context
                             .Gigs
                             //  TODO: check ownership
                             .SingleOrDefault(e => e.GigId == id);

                return
                    (new GigResource
                {
                    Date = entity.Date,
                    PostalCode = entity.PostalCode,
                    ArtistId = entity.ArtistId
                });
            }
        }
Ejemplo n.º 8
0
        public IEnumerable <RequestResource> GetRequests()
        {
            using (var context = new OneOffEntities())
            {
                var query = context
                            .Requests
                            .Select(
                    e =>
                    new RequestResource
                {
                    Date    = e.Date,
                    Offer   = e.Offer,
                    VenueId = e.VenueId
                }
                    );

                return(query.ToArray());
            }
        }
Ejemplo n.º 9
0
        public IEnumerable <GigResource> GetGigs()
        {
            using (var context = new OneOffEntities())
            {
                var query = context
                            .Gigs
                            .Select(
                    e =>
                    new GigResource
                {
                    Date       = e.Date,
                    PostalCode = e.PostalCode,
                    ArtistId   = e.ArtistId
                }
                    );

                return(query.ToArray());
            }
        }
Ejemplo n.º 10
0
        public bool CreateRequest(RequestResource request)
        {
            var entity =
                new Request()
            {
                Date    = request.Date,
                Offer   = request.Offer,
                VenueId = request.VenueId
            };

            using (var context = new OneOffEntities())
            {
                Venue venue = context
                              .Venues
                              .SingleOrDefault(v => v.VenueId == entity.VenueId);

                venue.Requests.Add(entity);
                context.Requests.Add(entity);
                return(context.SaveChanges() == 1);
            }
        }
Ejemplo n.º 11
0
        public bool CreateGig(GigResource gig)
        {
            var entity =
                new Gig()
            {
                Date       = gig.Date,
                PostalCode = gig.PostalCode,
                ArtistId   = gig.ArtistId
            };

            using (var context = new OneOffEntities())
            {
                Artist artist = context
                                .Artists
                                .SingleOrDefault(a => a.ArtistId == entity.ArtistId);

                artist.Gigs.Add(entity);
                context.Gigs.Add(entity);
                return(context.SaveChanges() == 1);
            }
        }