c# - An object reference is required for the non-static field, method, or property -
ive looked @ duplicate errors havent found solution
here method im implementing in business logic
public void updatebooking(bookingview model) { using (var booking = new bookingrepository()) { var user = new applicationuser(); booking book = booking.getbyid(model.bookingid); if (book != null) { book.bookingid = model.bookingid; book.bookingdate = model.bookingdate; book.bookingtime = model.bookingtime; book.location = model.location; //book.status = defaultstatus(); //book.treatmentname = book.treatmentname; //book.addinfo = model.addinfo; booking.update(book); } } }
but error on booking controller method
[httppost] [validateantiforgerytoken] public actionresult postponebooking([bind(include = "location,bookingdate,bookingtime")]bookingview model) { if (modelstate.isvalid) { bookingbusiness.updatebooking(model); } return redirecttoaction("bookingdetails", tempdata["alertmessage"] = "<script> alert('booking details saved!!');</script>"); }
exactly on line
bookingbusiness.updatebooking(model);
im clueless tried adding static methods still no luck.maybe im not understanding error need abit of guidance thank you
to use updatebooking
method, either bookingbusiness
class or updatebooking
method must static (you won't refer individual instance objects) or must instantiate object of type bookingbusiness
(obviously depending on how intend on implementing these):
bookingbusiness yourobject = new bookingbusiness(/*constructor args*/);
then can call method via yourobject.updatebooking(model);
Comments
Post a Comment