Hi,
So, I'm hacking together some changes to someone else's code.
Never understand why cSharp MVC make everything so difficult, its a job I could do in 5 minutes in VB script, but I'm stuck using CSharp despite its awfulness.
So, the scenario is a visitor registration database, we are adding a "limit" to the number of people who can book for a site on a particular day. The "limit" will be optional at a site level. Another scenario is that there will be a number of days in the future, you are allowed to book for, and not able to book after that date.
I've created the relevant objects to store that data at a site level, which, although displayed in an awful way for some reason, is basically working, and stored in the database against the site.
Now, when a booking is created for the relevant site, it simply needs to read the information from the site, lets say there is a limit of 50 people, compare that to the number of people booked for a given day, and display a warning (also defined at site level).
I'd settle for it simply being able to read the SQL I've entered as a starting point though.
That SQL is an a thing called "ISitesRepository", if it helps to give context is under "SiteVisitorRegister.Data\Interfaces\Repositories\SysAdmin\ISitesRepository.cs"
It looks like this:
public class IsFutureBookingLimitSupported
{
public IEnumerable<IsFutureBookingLimitSupported> GetFutureBookingLimitCheckbox(bool siteId, IDbConnection databaseConnection)
{
return
databaseConnection.Query<IsFutureBookingLimitSupported>(
"SELECT IsFutureBookingLimitSupported FROM [Sites] WHERE SiteId = @siteId ORDER BY Description", new { siteId });
}
// bool<IsFutureBookingLimitSupported> private SitesReposGetFutureBookingLimitCheckbox(string siteId);
}
That bit compiles OK, at least (no errors).
BUT - in another area, for context if it helps "VisitorRegister\SVR.WebClient\Controllers\Reg2Controller.cs"
I simply wish to call that code, inputting the SiteId from the "model", it would seem to be easy, no idea why they make it so hard, the logical way is:
ISitesRepository.GetFutureBookingLimitCheckbox(model.SiteId);
Here is the way's I've tried and the errors they are giving:
ISitesRepository.GetFutureBookingLimitCheckbox(model.SiteId); - An object reference is required for the non static field or property
var abISitesRepository = new ISitesRepository; - Cannot create an instance of the abstract class or interface ISitesRepository
void ISitesRepository -- Keyword void cannot be used in this context
Not sure what else to try.
Continue reading...