public async Task <IActionResult> Create([Bind("ImageID,Name,ImageFile")] ProgressPhotos imageModel, AddProgressPhotoViewModel addProgressPhotoViewModel)
        {
            if (ModelState.IsValid)
            {
                //save image to wwwroot folder
                string wwwrootPath = hostEnvironment.WebRootPath;
                string FileName    = Path.GetFileNameWithoutExtension(imageModel.ImageFile.FileName);
                string extension   = Path.GetExtension(imageModel.ImageFile.FileName);
                imageModel.Name = FileName = FileName + DateTime.Now.ToString("yymmssfff") + extension;
                string path = Path.Combine(wwwrootPath + "/Images/" + FileName);
                using (var fileStream = new FileStream(path, FileMode.Create))
                {
                    await imageModel.ImageFile.CopyToAsync(fileStream);
                }

                Plant          thePlant         = context.Plants.Find(addProgressPhotoViewModel.PlantId);
                ProgressPhotos newProgressPhoto = new ProgressPhotos
                {
                    Name      = addProgressPhotoViewModel.Name,
                    Plant     = thePlant,
                    PhotoName = addProgressPhotoViewModel.PhotoName
                };


                //insert record
                context.Add(imageModel);
                context.ProgressPhotos.Add(newProgressPhoto);
                await context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(imageModel));
        }
        public async Task <IActionResult> UpdatePlant(int id, Plant plant)
        {
            plant.id                    = id;
            plant.lastWatered           = DateTime.Now;
            _context.Entry(plant).State = EntityState.Modified;

            try {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlantExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(NoContent());
        }