public void DeletePeak(int id) { tblPeakHour hour = _context.tblPeakHours.Find(id); if (hour != null) { _context.tblPeakHours.Remove(hour); } }
public string AddDataToDB(string session, string mood) { var sI = cmbSession.SelectedIndex; tblPeakHour hour = new tblPeakHour(); hour.DateToday = Convert.ToDateTime(DateTime.Today.ToShortDateString()); hour.Session = session; hour.Mood = mood; if (hour.DateToday == DateTime.Today) { var model = context.tblPeakHours.Where(d => d.DateToday == DateTime.Today); if (model != null) { var checkSession = context.tblPeakHours.Where(s => s.Session == session).Count(); if (checkSession >= 1) { return("Session already captured"); } else { context.tblPeakHours.Add(hour); } } } int res = context.SaveChanges(); if (res >= 1) { return("Saved Successfully!"); } else { return("Item Not Saved"); } }
public void EditPeakHour(int id, tblPeakHour hour) { _context.Entry(hour).State = System.Data.Entity.EntityState.Modified; }
public void AddPeakHour(tblPeakHour hours) { _context.tblPeakHours.Add(hours); }