public void DeleteShift([FromBody] ShiftIdVM shiftId)
        {
            var token = Request.Headers["Authorization"].ToString().Replace("Bearer ", "");

            if (!PatManagerVerify.CheckIfManager(token, context))
            {
                //if the user isn't a manager then quit the method. Only managers are able to hire new people
                return;
            }
            //var query = context.Schedule.Where(s => s.ShiftId == shiftId.shiftId).FirstOrDefault();
            var query = (from s in context.Schedule where s.ShiftId == shiftId.ShiftId select s).First();

            context.Schedule.Remove(query);
            context.SaveChanges();
        }
        public bool PickUpShift([FromBody] ShiftIdVM shift)
        {
            //find out who wants to pick up the shift
            var token    = Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
            var handler  = new JwtSecurityTokenHandler();
            var tokenStr = handler.ReadJwtToken(token) as JwtSecurityToken;
            var userName = tokenStr.Claims.First(claim => claim.Type == "sub").Value;
            var user     = context.Users.Where(i => i.UserName == userName).FirstOrDefault();

            //now pull up the particular shift in question
            var theshift = context.DroppedShifts.Where(d => d.ShiftId == shift.ShiftId).FirstOrDefault();

            if (theshift != null)
            {
                //if the user is the same that is trying to pick up the shift
                if (theshift.EmpId == user.Id)
                {
                    return(false);
                }

                //Now check all the shifts that the user has, if one of them is the same day and week as the dropped shift then throw
                var userShifts = context.Schedule.Where(u => u.EmpId == user.Id);
                foreach (var us in userShifts)
                {
                    if (us.Week == theshift.Week && us.Day == theshift.Day)
                    {
                        //that user already works this day so they cannot take the shift
                        return(false);
                    }
                }

                //the two checks have been passed, now the new employee can be assigned to the shift
                var newShift = context.Schedule.Where(s => s.ShiftId == shift.ShiftId).FirstOrDefault();
                if (newShift != null)
                {
                    newShift.EmpId = user.Id;

                    context.DroppedShifts.Remove(theshift);

                    context.SaveChanges();

                    return(true);
                }
            }
            return(false);
        }
        public bool DropShift([FromBody] ShiftIdVM shift)
        {
            var theShift = context.Schedule.Where(s => s.ShiftId == shift.ShiftId).FirstOrDefault();

            if (theShift != null)
            {
                DroppedShift droppedShift = new DroppedShift
                {
                    ShiftId     = theShift.ShiftId,
                    EmpId       = theShift.EmpId,
                    Day         = theShift.Day,
                    Week        = theShift.Week,
                    StartTime   = theShift.StartTime,
                    UserDetails = theShift.UserDetails
                };
                context.DroppedShifts.Add(droppedShift);
                context.SaveChanges();
                return(true);
            }

            return(false);
        }