示例#1
0
        /// <summary>
        /// Adds a new TicketEventDate object to the database.
        /// </summary>
        /// <param name="ticketEventDate">TicketEventDateID, TicketEventID, VenueId, EventStartDateTime</param>
        public void EventDatesAdd(TicketEventDate ticketEventDate)
        {
            var output  = JsonConvert.SerializeObject(ticketEventDate);
            var client  = new RestClient(localhost);
            var request = new RestRequest("ticketeventdates", Method.POST);

            request.AddParameter("application/json", output, ParameterType.RequestBody);
            var response = client.Execute <TicketEventDate>(request);
        }
示例#2
0
        /// <summary>
        /// Updates a specific TicketEventDate object, selected by the TicketEventDateID.
        /// </summary>
        /// <param name="id">TicketEventDateID</param>
        /// <param name="ticketEventDate">TicketEventDateID, TicketEventID, VenueId, EventStartDateTime</param>
        public void EventDatesUpdate(int id, TicketEventDate ticketEventDate)
        {
            var output  = JsonConvert.SerializeObject(ticketEventDate);                     //Serialiaze'a objektet vi skickar in
            var client  = new RestClient(localhost);                                        //En instans av Restclient med adress
            var request = new RestRequest("ticketeventdates/{id}", Method.PUT);             //En instans av Restrequest med routing och metod info.

            request.AddUrlSegment("id", id);                                                //Addar id parametern till URL segementet
            request.AddParameter("application/json", output, ParameterType.RequestBody);    //content-type, data, det är request body vi skickar.
            var response = client.Execute <TicketEventDate>(request);                       //Exekuterar request med client och sparar i reponse.
        }
示例#3
0
 public TicketEventDate EventDatesUpdate(int id, TicketEventDate ticketEventDate)
 {
     using (var connection = new SqlConnection(connectionString))
     {
         connection.Open();
         connection.Query("UPDATE TicketEventDates SET TicketEventID = @ticketEventID, " + "VenueId = @venueID, " + "EventStartDateTime = @eventStartDateTime " + "WHERE TicketEventDateID = @ID",
                          new { ticketEventID = ticketEventDate.TicketEventID, venueID = ticketEventDate.VenueId, eventStartDateTime = ticketEventDate.EventStartDateTime, ID = id });
         return(connection.Query <TicketEventDate>("SELECT * FROM TicketEventDates WHERE TicketEventDateID=@Id", new { Id = id }).First());
     }
 }
        public void DateEventAdd(TicketEventDate newEventDate)
        {
            //var output = JsonConvert.SerializeObject(newVenue);
            var client  = new RestClient("http://localhost:54874");
            var request = new RestRequest("api/Event", Method.POST);

            request.AddJsonBody(newEventDate);
            //request.AddParameter("venue", output, ParameterType.RequestBody);
            client.Execute(request);
        }
示例#5
0
 public TicketEventDate EventDatesAdd(TicketEventDate ticketEventDate)
 {
     using (var connection = new SqlConnection(connectionString))
     {
         string queryString = "INSERT INTO TicketEventDates([TicketEventID],[VenueId],[EventStartDateTime]) VALUES(@TicketEventID,@VenueId, @EventStartDateTime)";
         connection.Open();
         connection.Query(queryString, new { TicketEventID = ticketEventDate.TicketEventID, VenueId = ticketEventDate.VenueId, EventStartDateTime = ticketEventDate.EventStartDateTime });
         var addedTicketEventDateQuery = connection.Query <int>("SELECT IDENT_CURRENT ('TicketEventDates') AS Current_Identity").First();
         return(connection.Query <TicketEventDate>("SELECT * FROM TicketEventDates WHERE TicketEventDateID=@Id", new { Id = addedTicketEventDateQuery }).First());
     }
 }
 public void Put(int id, [FromBody] TicketEventDate ticketEventDate)
 {
     if (ticketDb.FindTicketEventDateByID(id) == null)
     {
         Response.StatusCode = 404;
         return;
     }
     else
     {
         ticketDb.UpdateTicketEventDate(id, ticketEventDate.TicketEventID, ticketEventDate.VenueId, ticketEventDate.EventStartDateTime);
     }
 }
示例#7
0
        public ActionResult CreateTicketEventDate(int eventID, int venueID, DateTime dateTime)
        {
            TicketEventDate newDate = new TicketEventDate
            {
                TicketEventID      = eventID,
                VenueId            = venueID,
                EventStartDateTime = dateTime
            };

            ticketApi.EventDatesAdd(newDate);
            return(Redirect("AddTicketEventDate"));
        }
 public void AddNewTicketEventDate([FromBody] TicketEventDate ticketEventDate)
 {
     if (!ModelState.IsValid || ticketEventDate.VenueId <= 0)
     {
         Response.StatusCode = 400;
     }
     else
     {
         try
         {
             ticketDb.AddTicketEventDate(ticketEventDate.TicketEventID, ticketEventDate.VenueId, ticketEventDate.EventStartDateTime, ticketEventDate.NumberOfSeats);
         }
         catch (ArgumentException)
         {
             Response.StatusCode = 400;
         }
         catch (SqlException)
         {
             Response.StatusCode = 400;
         }
     }
 }
 public void Put(int id, [FromBody] TicketEventDate ticketEventDate)
 {
     tdb.EventDatesUpdate(id, ticketEventDate);
 }
 public TicketEventDate Post([FromBody] TicketEventDate ticketEventDate)
 {
     return(tdb.EventDatesAdd(ticketEventDate));
 }