I am trying to learn number of data in table in controller class. I was able to learn number of data in table in View class. But I couldn't apply View's code to Controller class.

View Class Code sth like that:

@model IEnumerable

@foreach (var item in Model) {

if (item.Capacity == 1 && item.Records.Count() != 0)
{
  ............
}

}

It works(count the number of table) But in controller class how can I convert code to controller class?

public ActionResult Create([Bind(Include = "RecordID,SID,CID,CName")] Record record) {

        if (ModelState.IsValid)
        {

                    db.Records.Add(record);
                    db.SaveChanges();
                    return RedirectToAction("Index");


        }

Related posts

Recent Viewed