Gcobani Mkontwana

Gcobani Mkontwana

  • 1k
  • 1.4k
  • 155.7k

How to use your database to display record list

Sep 23 2021 6:42 AM

Hi Team

I am bit struggling to call a record(datetime column) from local database, so far its hard coded and need some help around it. Let me share this logic both on controller and model class. The code works but i want to pull the data directly from the database.

// Model

  public class Dashboard
    {

        // Map all values from the record list in TimeLine Application DB.


        public int Incident { get; set; }


        public DateTime FromDateTime { get; set; }

        public DateTime ToDate { get; set; }


        public string Resources { get; set; }


        public string Description { get; set; }


        public int EndDate { get; set; }
    }

 

// Controller .cs

   public JsonResult GetAll()
        {
            return Json(DashboardTimeLine(), JsonRequestBehavior.AllowGet);
        }

        public List DashboardTimeLine()
        {
            List timeList = new List();
            timeList.Add(new Dashboard { Incident = 1, FromDateTime = new DateTime(2021, 09, 23, 08, 01, 43), ToDate = new DateTime(2021, 08, 10, 15, 23, 48) });
            timeList.Add(new Dashboard { Incident = 2, FromDateTime = new DateTime(2021, 09, 23, 07, 05, 15), ToDate = new DateTime(2021, 08, 23, 07, 05, 49) });
            timeList.Add(new Dashboard { Incident = 3, FromDateTime = new DateTime(2021, 09, 23, 07, 05, 15), ToDate = new DateTime(2021, 07, 15, 05, 56, 10) });
            return timeList;
        }

 

 


Answers (3)