Beispiel #1
0
        public async Task <IHttpActionResult> PostVenue(VenueResource venue)
        {
            var venueService = new VenueService();
            await venueService.CreateVenue(venue);

            return(Ok(venue));
        }
Beispiel #2
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);
            }
        }
        public OperationResult Post(VenueResource newVenueResource)
        {
            var addVenueCommand = new AddVenueCommand(
                venueName: newVenueResource.Name,
                address: newVenueResource.Address,
                mapURN: newVenueResource.MapURN,
                contact: newVenueResource.Contact);

            commandProcessor.Send(addVenueCommand);

            var venue = new VenueTranslator().Translate(
                new VenueReader(_unitOfWorkFactory, false)
                .Get(addVenueCommand.Id)
                );

            return(new OperationResult.Created()
            {
                ResponseResource = venue,
                CreatedResourceUrl = new Uri(venue.Links[0].HRef)
            });
        }
        public OperationResult Put(Guid id, VenueResource venueResource)
        {
            var updateVenueCommand = new UpdateVenueCommand(
                id: id,
                venueName: venueResource.Name,
                address: venueResource.Address,
                mapURN: venueResource.MapURN,
                contact: venueResource.Contact,
                version: venueResource.Version);

            commandProcessor.Send(updateVenueCommand);

            var venue = new VenueTranslator().Translate(
                new VenueReader(_unitOfWorkFactory, false)
                .Get(updateVenueCommand.Id)
                );

            return(new OperationResult.OK
            {
                ResponseResource = venue
            });
        }