Hi Team
I want to make my save functionality to work, but it does not keep any record to my table and need some help. In summary what i want here is when a user creates a course, the coursename must stored to the table as raw data, so can see it to the course dashboard. Mine does not keep any record, here my logic below;
- [Route("Home/CoursesRegistration")]
- public ActionResult CoursesRegistration( eNtsaRegCourses collection)
- {
- if(ModelState.IsValid)
- {
- cb.SaveChanges();
- return RedirectToAction("Courses", "Home");
- }
- return View(collection);
- }
- //GET://Courses/Courses-All.
- [Route("Home/Courses")]
- public ActionResult Courses(string g) // This method must keep those record, when user register the course-name.
- {
- return View(g);
- }
- // Model
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Data.Entity;
- using eNtsaRegistrationTraining.Models;
- namespace eNtsaRegistrationTraining.DAL
- {
- public class eNtsaRegCourses:DbContext
- {
- public eNtsaRegCourses(): base("eNtsaRegCourses")
- {
- }
- public DbSet
eNtsaCourse { get; set; } - protected override void OnModelCreating(DbModelBuilder modelBuilder)
- {
- Database.SetInitializer
(null); - base.OnModelCreating(modelBuilder);
- }
- }
- }
- // Model
- // db-schema lists.
- public class eNtsaCourses
- {
- [Key]
- public Guid? Id { get; set; }
- public string Course { get; set; }
- public string Nickname { get; set; }
- public string Term { get; set; }
- public string EnrolledAs { get; set; }
- public bool Published { get; set; }
- }
- // View
- class="modal-footer">
- class="btn btn-secondary" data-dismiss="modal">Cancel
- class="btn btn-large btn-success" id="fire" href="@Url.Action("CoursesRegistration", "Home")">Create Courses
Salman BegPosted Aug 19, 2020, 9:42 AM
Guest UserPosted Aug 19, 2020, 9:30 AM
Salman BegPosted Aug 19, 2020, 9:20 AM