public String Count(int ID) { try { Roll_Call check = base.db.Roll_Call.Where(c => c.UserID == ID).FirstOrDefault(); Monthly_Schedule set = base.db.Monthly_Schedule.Where(m => m.UserID == ID).FirstOrDefault(); String output = null; if (set != null) { if (check == null) { check = new Roll_Call(); check.Count = true; check.UserID = ID; check.Created = DateTime.Today; base.db.Roll_Call.Add(check); base.db.SaveChanges(); } else { if (DateTime.Compare(Convert.ToDateTime(check.Created.ToString()), DateTime.Today) == 0) { output = "AlreadyCount"; } else { check.Count = true; check.Created = DateTime.Today; base.db.SaveChanges(); } } if (output != "AlreadyCount") { set.TotalCount = (set.TotalCount != null) ? (set.TotalCount + 1) : (1); base.db.SaveChanges(); return("true"); } return(output); } else { return("MonthlyScheduleNotSet"); } } catch (Exception) { return("false"); } }
public bool isCount(int ID) { try { Roll_Call select = base.db.Roll_Call.Where(u => u.UserID == ID).FirstOrDefault(); if (select != null) { return((DateTime.Compare(Convert.ToDateTime(select.Created.ToString()), DateTime.Today) == 0) ? (true) : (false)); } else { return(false); } } catch (Exception ex) { return(false); } }