我正在尝试在数据库表中添加出勤时间和出勤时间,并计算加班总时间

时间:2019-04-23 05:46:49

标签: asp.net-mvc

我正在尝试计算加班时间

public ActionResult Attendence()
{
   // Accessing database 
   var hour = db.Student_Attendence.ToList();
   List<HoursSpent> hourlist = new List<HoursSpent>();
   HoursSpent spent = new HoursSpent();
   var entertime = spent.InTime;

   foreach (var item in hour)
   {
       // since starttime is a string in the db and intime is DateTime.
       item.Student.StartTime = Convert.ToString(entertime);
       item.Student.Name = spent.Name;
       item.DateTime = spent.Date;

       var exittime = spent.OutTime;

       item.Student.EndTime = Convert.ToString(exittime);
       var totaltime = spent.Hourspent;

       if (exittime != null)
       {
           totaltime = exittime - entertime;
       }

       hourlist.Add(item);
   }          

   return View(hourlist);

}

0 个答案:

没有答案