Ejemplo n.º 1
0
        public HttpResponseMessage EditVenue(IncomingEditVenue addVenue)
        {
            return(ErrorFactory.Handle(() =>
            {
                var userId = User?.Identity?.GetUserId();

                if (string.IsNullOrWhiteSpace(userId))
                {
                    throw new Exception();
                }

                using (var unitOfWork = new UnitOfWork())
                {
                    var editVenue = unitOfWork.Venues.EditVenue(userId, addVenue);

                    unitOfWork.Complete();

                    try
                    {
                        editVenue = unitOfWork.Venues.GetVenueById(userId, editVenue.Id);
                    }
                    catch (Exception)
                    {
                    }

                    var outgoingVenue = OutgoingVenue.Parse(editVenue);

                    return JsonFactory.CreateJsonMessage(outgoingVenue, HttpStatusCode.OK, this.Request);
                }
            }, this.Request));
        }
Ejemplo n.º 2
0
        public Venues EditVenue(string userId, IncomingEditVenue addVenue)
        {
            var canEdit = this.CanUserEditVenues(userId, addVenue.Id);

            if (canEdit == false)
            {
                throw new UnauthorizedAccessException();
            }

            var venue = this.dbContext.Venues.FirstOrDefault(x => x.Id == addVenue.Id);

            if (venue == null)
            {
                throw new Exception("Unable to find the incoming venue.");
            }

            venue.Name = addVenue.Name;

            venue.IsHidden = addVenue.IsHidden;

            return(venue);
        }