Project Work Answers of The Events User Controller- COMP5347

Project Work Answers of The Events User Controller- COMP5347

Model Classes
EventDetails
public class EventDetails
{
[System.ComponentModel.DataAnnotations.Key]
public int I …

Preview text

Model Classes
EventDetails
public class EventDetails
{
[System.ComponentModel.DataAnnotations.Key]
public int Id { get ; set ; }
public string EventTitle { get ; set ; }
public string GuestName { get ; set ; }
public string EventDate { get ; set ; }
}
This class is responsible for representing fields present in the database, which are responsible for storing user details.
It is mainly responsible for creation and updating the EventTitle, GuestName and EventDate fields in the database.
RegistrationDetails
public class RegistrationDetails
{
[System.ComponentModel.DataAnnotations.Key]
public int Id { get ; set ; }
public string Email { get ; set ; }
public string UserName { get ; set ; }
}
This class is responsible for representing fields present in the database , which are responsible for storing user details.
It is mainly responsible for creation and updating the Email and Username fields in the database.
The EventsUserController constructor is injected by two things, ILogger responsible for logging erro rs and
EventDatabaseContext that connects to the database instance.
Controller Classes
public class EventstUserController : Controller
{
priva te readonly EventDatabaseContext _eventDatabaseContext;
private readonly ILogger _logger;
public EventstUserController (ILogger logger, EventDatabaseContext
eventDatabaseContext)
{
_logger = logger;
_eventDatabaseContext = eventDatabaseContext;
}
public IActionResult Index()
{
return View();
}
public IActionResult Registration(RegistrationDetails registrationDetails)
{
//Maps to the Model Class and Database fields
//Them Model and Controller have database fields
//representations which are case sensitive
var _RegistrationDetails = new RegistrationDetails
{
Email = registrationDetails.Email,
UserName = registrationDetails.UserName,
};
// checks for non null fields.
if ((registrationDetails.Email != null ) && (registrationDetails.UserName != null ))
{
_eventDatabaseContext.RegistrationDetails.Add(_RegistrationDetails);
_eventDatabaseContext.SaveChanges();
//Wh en the form action has been submited
//it routes back to the default page
return RedirectToAction( “Index” , “Home” );
}
else
{
//When Form action is null it maintain current page
return View(_RegistrationDetails);
}
}
}
Implement ation of the EventstUserController is responsible for handl ing user input from a form and store in the
database ; also responsible for redirecting user back to homepage upon successful input collection else the user
remains on current page.
The EventstUserController constructor is injected by two things, ILogger responsible for logging errors and
EventDatabaseContext that connects to the database instance and li kewise the
private readonly EventDatabaseContext _eventDatabaseContext;
private readonly ILogger _logger;
public EventsGuestController (ILogger logger, EventDatabaseContext
eventData baseContext)
{
_logger = logger;
_eventDatabaseContext = eventDatabaseContext;
}
public IActionResult Index()
{
return View();
}
public IActionResult EventCreation(EventDetails eventDetails)
{
//Maps to the Model Class and Database fields
//Them Model and Controller have database fields
//representations which are case sensitive
var _EventDetails = new EventDetails
{
EventTitle = eventDetails.EventTitle,
GuestName = eventDetails.GuestName,
EventDate = eventDetails.EventDate
};
// checks for non nul l fields.
if (
(eventDetails.EventTitle != null ) &&
(eventDetails.GuestName != null ) &&
(eventDetails.EventDate != null )
)
{
_eventDatabaseContext.Event Details.Add(_EventDetails);
_eventDatabaseContext.SaveChanges();
//When the form action has been submited
//it routes back to the default page
return RedirectToAction( “Index” , “Home” );
}
else
{ //When Form action is null it maintain current page
return View(_EventDetails);
}
}
}
Implement ation of the EventsGuestController is responsible for handl ing user input from a form and store in the
database ; also responsible for redirecting user back to homepage upon successful input collection else the user
remains on current page.
The EventsGuestController constructor is injected by two things, ILogger responsible for logging errors and
EventDatabaseContext that connects to the database instance .
So, in conclusion the controllers are communication channels that link Modes to Views and are responsible for
processing inputs from the user and updating the views accordingly after the inputs are posted to the database.
Views
1. CareerEvents
2. ErrorPage
3. EventsGuest
4. EventsUser
5. Home
6. KnowledgeSupport
7. Techni calEvent
Only two view s have been implemented , one for guest speaker to create (EventsGuest) an event and the other for the
student to enroll to the event created by the speaker (EventsUsers). The Home view was generated by default. The
error page is specially designed to handle errors that can only be seen by the deve loper only.
In the coming as signment the remaining view will be implemented as per the name of the view suggested. The Career
events page will be responsible for hosting upcoming career talks and challenges. The knowledge support page will
host material that can be used to offer guid ance on the career path chosen. The Technical event will be hosting
bootcamps for coding challenges that the students are expected to attend.
HomeView responsible for hosting a beautiful landing page.
EventsCreation View , facilitates guest speaker to be able to create events that he or she will be hosting on
premise or online.
Registration View for student to enroll to event.
Actions
1. EventCreation
2. Registration
Only two ActionResults we implemented as indicated above.
public IActionResult EventCreation(EventDetails eventDetails)
{
//Maps to the Model Class and Database fields
//Them Model and Controller have database fields
//representations which are case sensitive
var _EventDetails = new EventDetails
{
EventTitle = eventDetails.EventTitle,
GuestName = eventDetails.GuestName,
EventDate = eventDetails.EventDate
};
// che cks for non null fields.
if (
(eventDetails.EventTitle != null ) &&
(eventDetails.GuestName != null ) &&
(eventDetails.EventDate != null )
)
{
_eventDataba seContext.EventDetails.Add(_EventDetails);
_eventDatabaseContext.SaveChanges();
//When the form action has been submited
//it routes back to the default page
return RedirectToAction( “Index” , “Home” );
}
else
{ //When Form action is null it maintain current page
return View(_EventDetails);
}
}
The EventDetails action result maps to the database filed and stores information inputted by the guest
speaker. EventDetails is an intermediary between the model class and view class. This class also contains an
If statement that checks the in-put form before a user proceeds to click on the create button.
public IActionR esult Registration(RegistrationDetails registrationDetails)
{
//Maps to the Model Class and Database fields
//Them Model and Controller have database fields
//representations which are case sensitive
var _RegistrationDetails = new RegistrationDetails
{
Email = registrationDetails.Email,
UserName = registrationDetails.UserName,
};
// checks for non null fields.
if ((regist rationDetails.Email != null ) && (registrationDetails.UserName != null ))
{
_eventDatabaseContext.RegistrationDetails.Add(_RegistrationDetails);
_eventDatabaseContext.SaveChanges();
//When the form action has been submited
//it routes back to the default page
return RedirectToAction( “Index” , “Home” );
}
else
{
//When Form action is null it maintain current page
return View(_RegistrationDetails);
}
}
}
The Registration action result maps to the database filed and stores information inputted by the student who
enrolls to a particular event. Registration is an intermediary be tween the model class and view class.
This class also contains an If statement that checks the in -put form before a user proceeds to click on the
BookSlot button.

Order Now

QUALITY: 100% ORIGINAL PAPER – NO PLAGIARISM – CUSTOM PAPER