예제 #1
0
        public bool CheckIfExists(ShiftLengths shiftLength)
        {
            var count = _context.ShiftLengths.Select(s => s.Shift).Where(s => s.Equals(shiftLength.Shift)).Count();

            if (count > 0)
            {
                return(true);
            }
            return(false);
        }
예제 #2
0
 public ActionResult NewShift(ShiftLengths newShift)
 {
     try
     {
         newShift.Shift = Convert.ToDouble(newShift.Shift);
         bool exists = CheckIfExists(newShift);
         if (!exists)
         {
             newShift.Display = true;
             _context.ShiftLengths.Add(newShift);
             _context.SaveChanges();
         }
         else
         {
             return(RedirectToAction(RetryDialogueBox("This input already exists. Click retry to enter a new number.", "Duplicate Input.", "AddShiftLengths")));
         }
     }
     catch
     {
         return(RedirectToAction(RetryDialogueBox("Input can only contain a number. Click retry to enter a new number.", "Invalid Input.", "AddShiftLengths")));
     }
     return(RedirectToAction("AddShiftLengths"));
 }