Exemplo n.º 1
0
        public bool CheckIfExists(ShiftStartTimes shiftStart)
        {
            var count = _context.ShiftStartTimes.Select(s => s.ShiftStartTime).Where(s => s.Equals(shiftStart.ShiftStartTime)).Count();

            if (count > 0)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
 public ActionResult NewShiftStartTime(ShiftStartTimes newShiftStartTime)
 {
     try
     {
         newShiftStartTime.ShiftStartTime = Convert.ToDouble(newShiftStartTime.ShiftStartTime);
         bool exists = CheckIfExists(newShiftStartTime);
         if (!exists)
         {
             newShiftStartTime.Display = true;
             _context.ShiftStartTimes.Add(newShiftStartTime);
             _context.SaveChanges();
         }
         else
         {
             return(RedirectToAction(RetryDialogueBox("This input already exists. Click retry to enter a new number.", "Duplicate Input.", "AddShiftStartTimes")));
         }
     }
     catch
     {
         return(RedirectToAction(RetryDialogueBox("Input can only contain a number.\nClick retry to input a new number.", "Invalid Input.", "AddShiftStartTimes")));
     }
     return(RedirectToAction("AddShiftStartTimes"));
 }