Example #1
0
        public void DeletePeak(int id)
        {
            tblPeakHour hour = _context.tblPeakHours.Find(id);

            if (hour != null)
            {
                _context.tblPeakHours.Remove(hour);
            }
        }
Example #2
0
        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");
            }
        }
Example #3
0
 public void EditPeakHour(int id, tblPeakHour hour)
 {
     _context.Entry(hour).State = System.Data.Entity.EntityState.Modified;
 }
Example #4
0
 public void AddPeakHour(tblPeakHour hours)
 {
     _context.tblPeakHours.Add(hours);
 }