//============CREATE==============//
        //Create all tasks TESTING
        //[ActionName("CreateTasksForEverything")]
        public async Task <bool> CreateTasksForEverything()
        {
            List <int> currentTasksForMachine = new List <int>();

            bool okToAdd = true;

            foreach (TasksForMachine existing in _context.TasksForMachines)
            {
                currentTasksForMachine.Add(existing.MaintenanceTaskId);
            }

            foreach (MaintenanceTask task in _context.Tasks)
            {
                if (task.Active == false)
                {
                    okToAdd = false;
                }

                foreach (int existingId in currentTasksForMachine)
                {
                    if (existingId == task.MaintenanceTaskId)
                    {
                        okToAdd = false;
                        break;
                    }
                }

                if (okToAdd)
                {
                    //takes in a datetimeoffset and converts it to weekday
                    DateTimeOffset dateTimeOffset = DateTimeOffset.Now + TimeSpan.FromTicks(task.MaintenanceTaskInterval);
                    Methods        helperMethod   = new Methods();

                    DateTimeOffset modifiedDate = helperMethod.ConvertToDayOfWeek(dateTimeOffset);

                    //takes in a datetimeoffset and converts only the time to 5:00pm
                    DateTimeOffset modifiedTime = helperMethod.ConvertToEndOfDayTime(modifiedDate);

                    TasksForMachine taskMachine =
                        new TasksForMachine()
                    {
                        MachineId            = task.MachineId,
                        NeedToBeMaintainedBy = modifiedTime,
                        MaintenanceTaskId    = task.MaintenanceTaskId,
                        ApplicationUserId    = task.ApplicationUserId
                    };

                    _context.TasksForMachines.Add(taskMachine);
                }

                okToAdd = true;
            }

            return(await _context.SaveChangesAsync() >= 1);
        }
        //===========Update=============//
        public async Task <bool> CompleteAndGenerateNewTasksForMachineById([FromUri] int id)
        {
            var entity =
                _context
                .TasksForMachines
                .SingleOrDefault(tm => tm.Id == id);

            entity.Maintained        = DateTime.Now;
            entity.ApplicationUserId = _userId.ToString();

            MaintenanceTask refrence =
                _context
                .Tasks
                .SingleOrDefault(t => t.MaintenanceTaskId == entity.MaintenanceTaskId);

            //get datetimeoffset and modify time and day to be on a weekday at 5:00pm for need to be maintained by prop
            //takes in a datetimeoffset and converts it to weekday
            DateTimeOffset dateTimeOffset = DateTimeOffset.Now + TimeSpan.FromTicks(refrence.MaintenanceTaskInterval);
            Methods        helperMethod   = new Methods();

            DateTimeOffset modifiedDate = helperMethod.ConvertToDayOfWeek(dateTimeOffset);

            //takes in a datetimeoffset and converts only the time to 5:00pm
            DateTimeOffset modifiedTime = helperMethod.ConvertToEndOfDayTime(modifiedDate);


            TasksForMachine newTaskMachine = new TasksForMachine()
            {
                MachineId            = refrence.MachineId,
                NeedToBeMaintainedBy = modifiedTime,
                MaintenanceTaskId    = refrence.MaintenanceTaskId,
                ApplicationUserId    = refrence.ApplicationUserId
            };

            _context.TasksForMachines.Add(newTaskMachine);

            return(await _context.SaveChangesAsync() >= 1);
        }