Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8079349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:04:25+00:00 2026-06-05T16:04:25+00:00

I have a booking app, which accepts a single booking object, and works ok.

  • 0

I have a booking app, which accepts a single “booking” object, and works ok. My question is, how do I convert this to accept multiple records (from JSON):

Booking.cs

namespace MvcApplication4.Models
{
    public class Booking
    {
        [Key()]
        public long ID { get; set; }
        public long? HID { get; set; }
        public long RID { get; set; }
        public string Occ { get; set; }
        public DateTime CI { get; set; }
        public DateTime CO { get; set; }
        public long? CID { get; set; }
    }
}

BookingsContext.cs

namespace MvcApplication4.Models
{
    public class BookingsContext : DbContext
    {
    public BookingsContext() : base("name=BookingsContext")
    {
    }
    public DbSet<Booking> Bookings { get; set; }            
    }
}

BookingsController.cs

    // POST api/Bookings
        public HttpResponseMessage PostBooking(Booking booking)
        {
            if (ModelState.IsValid)
            {
                    // Add the booking
                    db.Bookings.Add(booking);
                    db.SaveChanges();
                    HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, booking);
                    response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = booking.RID }));
                    return response;
                }
            }

The JSON currently passed is:

var comment = {ID:0, HID: $('#HID').val(), RID:$('#RID').val(), Occ:$('#Occ').val(), CI:$('#CI').val(), CO:$('#CO').val(), CID:$('#CID').val()},{ID:0, HID: $('#HID').val(), RID:$('#RID').val(), Occ:$('#Occ').val(), CI:$('#CI').val(), CO:$('#CO').val(), CID:$('#CID').val()};

How can I pass multiple records to the controller, so that I don’t have to call the JSON Post method may times?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:04:27+00:00Added an answer on June 5, 2026 at 4:04 pm

    You could modify the signature of your action to take an array of Booking:

    public HttpResponseMessage PostBooking(Booking[] bookings)
    {
        ...
    }
    

    and then send an array of booking from the client:

    var bookings =
        [
            {
                ID: 0,
                HID: 'hid1',
                RID: 'rid1',
                Occ: 'occ1',
                CI: 'ci1',
                CO: 'co1',
                CID: 'cid1'
            },
            {
                ID: 1,
                HID: 'hid2',
                RID: 'rid2',
                Occ: 'occ2',
                CI: 'ci2',
                CO: 'co2',
                CID: 'cid2'
            }
        ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have written this little class, which generates a UUID every time an object of
I have tons of ajax components on this booking engine. I need to customize
I have a php MySql booking calendar, which shows whether the room is booked
I have created Live Wallpaper app. When I start this via Wallpapers -> Live
I am making a booking app now and have a problem. I need a
I have a rails app which uses omniauth to authenticate visitors via facebook. When
I have a booking system in which I need to select any available room
I have a Booking controller class (generated, NetBeans), having update method, called from JSF
So I have a booking system where I have a 'lesson_type' table with 'lesson_type_id'
I have the following table SEASONS with time periods defining a booking prices for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.