public async Task <IActionResult> Create([Bind("Id,Name,Smarts,Image")] AppFunctionalgroup appFunctionalgroup)
        {
            if (appFunctionalgroup.Image != null && appFunctionalgroup.Image.Length > 0)
            {
                var file = System.IO.File.Open(appFunctionalgroup.Image, System.IO.FileMode.Open);
                appFunctionalgroup.Image = "Images/FunctionalGroups/" + System.IO.Path.GetFileName(file.Name);
                //There is an error here
                //var uploads = System.IO.Path.Combine(_appEnvironment.WebRootPath, "uploads\\img");
                if (file.Length > 0)
                {
                    var fileName = _hostingEnvironment.WebRootPath + "\\Images\\FunctionalGroups\\" + System.IO.Path.GetFileName(file.Name);
                    using (var stream = new System.IO.FileStream(fileName, System.IO.FileMode.Create))
                    {
                        await file.CopyToAsync(stream);
                    }
                }
                file.Close();
            }

            if (ModelState.IsValid)
            {
                _context.Add(appFunctionalgroup);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(appFunctionalgroup));
        }
        public async Task <IActionResult> Edit(long id, [Bind("Id,Name,Smarts,Image")] AppFunctionalgroup appFunctionalgroup)
        {
            if (id != appFunctionalgroup.Id)
            {
                return(NotFound());
            }

            if (appFunctionalgroup.Image != null && appFunctionalgroup.Image.Length > 0)
            {
                var file = System.IO.File.Open(appFunctionalgroup.Image, System.IO.FileMode.Open);
                appFunctionalgroup.Image = "Images/FunctionalGroups/" + System.IO.Path.GetFileName(file.Name);
                //There is an error here
                //var uploads = System.IO.Path.Combine(_appEnvironment.WebRootPath, "uploads\\img");
                if (file.Length > 0)
                {
                    var fileName = _hostingEnvironment.WebRootPath + "\\Images\\FunctionalGroups\\" + System.IO.Path.GetFileName(file.Name);
                    using (var stream = new System.IO.FileStream(fileName, System.IO.FileMode.Create))
                    {
                        await file.CopyToAsync(stream);
                    }
                }
                file.Close();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(appFunctionalgroup);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AppFunctionalgroupExists(appFunctionalgroup.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(appFunctionalgroup));
        }