public async Task <IActionResult> Edit(List <Availability> model, string id)
        {
            var user = await userManager.FindByIdAsync(id);

            if (user.Id != id)
            {
                return(Forbid());
            }

            if (user == null)
            {
                return(NotFound());
            }

            foreach (var m in model)
            {
                var databaseAvailability = availabilityRepository.GetAvailabilityByAvailabilityID(m.AvailabilityID);
                if (databaseAvailability != null)
                {
                    if (m.IsSelected && !databaseAvailability.IsSelected)
                    {
                        databaseAvailability.IsSelected = true;
                        await availabilityRepository.Update(databaseAvailability);
                    }
                    else if (!m.IsSelected && databaseAvailability.IsSelected)
                    {
                        databaseAvailability.IsSelected = false;
                        await availabilityRepository.Update(databaseAvailability);
                    }
                }
            }

            return(RedirectToAction("index", "availability", new { id = id }));
        }
        public async Task <AvailabilityResponse> UpdateAsync(int id, Availability availability)
        {
            var existingavailability = await _availabilityRepository.FindByIdAsync(id);

            if (existingavailability == null)
            {
                return(new AvailabilityResponse(" availability not found"));
            }

            existingavailability.DayAvailability = availability.DayAvailability;
            existingavailability.StartTime       = availability.DayAvailability;
            existingavailability.EndTime         = availability.DayAvailability;

            try
            {
                _availabilityRepository.Update(existingavailability);
                await _unitOfWork.CompleteAsync();

                return(new AvailabilityResponse(existingavailability));
            }
            catch (Exception ex)
            {
                return(new AvailabilityResponse($"An error ocurred while updating the Availability: {ex.Message}"));
            }
        }