public IActionResult DeleteFromAll(ReadingDeleteFromAllViewModel model)
        {
            if (model.Id == null)
            {
                return(RedirectToAction("AllFromUser", "Reading", new { rmessage = ReadingMessageId.ReadingNotFound }));
            }

            if (!ModelState.IsValid)
            {
                return(RedirectToAction("AllFromUser", "Reading", new { rmessage = ReadingMessageId.ValidationFailed }));
            }

            try
            {
                Reading reading = _readingsRepo.GetReading(model.Id);

                string authUserId = GetCurrentUserAsync().Result.Id;
                if (!reading.Owner.UserId.Equals(authUserId))
                {
                    return(RedirectToAction("AllFromUser", "Reading", new { rmessage = ReadingMessageId.NotAuthorized }));
                }

                _readingsRepo.Delete(reading);
                _logger.LogInformation("User deleted one Reading.");
                return(RedirectToAction("AllFromUser", "Reading", new { rmessage = ReadingMessageId.DeleteReadingSuccess }));
            }
            catch (Exception ex)
            {
                _logger.LogInformation(ex.Message);
                return(RedirectToAction("AllFromUser", "Reading", new { rmessage = ReadingMessageId.DeleteReadingFailed }));
            }
        }
        public IActionResult DeleteFromAll(string readingId)
        {
            if (readingId == null)
            {
                return(RedirectToAction("AllFromUser", "Reading", new { rmessage = ReadingMessageId.ReadingNotFound }));
            }

            Reading reading = _readingsRepo.GetReading(readingId);

            if (reading == null)
            {
                return(RedirectToAction("AllFromUser", "Reading", new { rmessage = ReadingMessageId.ReadingNotFound }));
            }

            if (!reading.Owner.UserId.Equals(GetCurrentUserAsync().Result.Id))
            {
                return(RedirectToAction("AllFromUser", "Reading", new { rmessage = ReadingMessageId.NotAuthorized }));
            }

            var model = new ReadingDeleteFromAllViewModel
            {
                Id        = reading.Id,
                Name      = reading.Name,
                ReadValue = reading.ReadValue,
                Timestamp = reading.Timestamp
            };

            ViewData["readingType"] = reading.ReadingType.Name;

            return(PartialView(model));
        }