public HttpResponseMessage AddVenue(CreateVenues venue) { return(ErrorFactory.Handle(() => { var userId = User?.Identity?.GetUserId(); if (string.IsNullOrWhiteSpace(userId)) { throw new Exception(); } using (var unitOfWork = new UnitOfWork()) { var returnedVenue = unitOfWork.Venues.CreateVenue(userId, venue); unitOfWork.Complete(); try { returnedVenue = unitOfWork.Venues.GetVenueById(userId, returnedVenue.Id); } catch (Exception) { } var outgoingVenue = OutgoingVenue.Parse(returnedVenue); return JsonFactory.CreateJsonMessage(outgoingVenue, HttpStatusCode.OK, this.Request); } }, this.Request)); }
public Venues CreateVenue(string userId, CreateVenues addVenue) { var canAdd = this.CanUserAddVenues(userId, addVenue.HotelId); if (canAdd == false) { throw new UnauthorizedAccessException(); } var newVenue = new Venues { Name = addVenue.Name, HotelId = addVenue.HotelId, Type = addVenue.VenueTypeId, IsHidden = addVenue.IsHidden }; this.dbContext.Venues.Add(newVenue); return(newVenue); }