public IActionResult DetailsEdit(DateTime date)
        {
            var           details = service.GetDetailsByDate(date);
            DetailsEditVM editVM  = service.GetDetailsEditVM(details);

            return(View(editVM));
        }
        //----------Update/Edit details-------------//

        internal void EditDetails(DetailsEditVM editVM, DateTime date)
        {
            if (editVM.ImageUpload != null)
            {
                var filePath = Path.Combine(webHostEnv.WebRootPath, "Uploads", editVM.ImageUpload.FileName);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    editVM.ImageUpload.CopyTo(fileStream);
                }
            }

            string userId = userManager.GetUserId(
                accessor.HttpContext.User);

            var dayToUpdate = context.StatsTables
                              .Where(x => x.Date == date)
                              .SingleOrDefault(x => x.UserId == userId);

            dayToUpdate.Mood             = editVM.Mood;
            dayToUpdate.Stress           = editVM.Stress;
            dayToUpdate.PhysicalActivity = editVM.PhysicalActivity;
            dayToUpdate.Sleep            = editVM.Sleep;
            dayToUpdate.MentalHealth     = editVM.MentalHealth;
            dayToUpdate.PhysicalHealth   = editVM.PhysicalHealth;
            dayToUpdate.Notes            = editVM.Notes;
            if (editVM.ImageUpload != null)
            {
                dayToUpdate.ImagePath = editVM.ImageUpload?.FileName;
                dayToUpdate.HasImage  = editVM.ImageUpload?.FileName.Length > 0;
            }

            context.SaveChanges();
        }
        public IActionResult DetailsEdit(DetailsEditVM editVM, DateTime date)
        {
            if (!ModelState.IsValid)
            {
                return(View(editVM));
            }

            service.EditDetails(editVM, date);
            return(RedirectToAction(nameof(Details), new { date = editVM.Date.ToShortDateString() }));
        }