public async Task <IActionResult> Create([Bind("Title,Upload,Photo,Id,Content")] HomeSpecialityDoctor homeDoctor)
        {
            if (homeDoctor.Upload == null)
            {
                ModelState.AddModelError("Upload", "Şəkil məcburidir");
            }
            else
            {
                if (homeDoctor.Upload.ContentType != "image/jpeg" && homeDoctor.Upload.ContentType != "image/png" && homeDoctor.Upload.ContentType != "image/gif")
                {
                    ModelState.AddModelError("Upload", "Siz yalnız png,jpg və ya gif faylı yükləyə bilərsiniz");
                }

                if (homeDoctor.Upload.Length > 1048576)
                {
                    ModelState.AddModelError("Upload", "Fayl ölcüsu maximum 1MB ola bilər");
                }
            }
            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(homeDoctor.Upload);
                homeDoctor.Photo = fileName;

                _context.Add(homeDoctor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(homeDoctor));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Title,Upload,Photo,Id,Content")] HomeSpecialityDoctor homeDoctor)
        {
            if (id != homeDoctor.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (homeDoctor.Upload != null)
                    {
                        if (homeDoctor.Upload.ContentType != "image/jpeg" && homeDoctor.Upload.ContentType != "image/png" && homeDoctor.Upload.ContentType != "image/gif")
                        {
                            ModelState.AddModelError("Upload", "Siz yalnız png,jpg və ya gif faylı yükləyə bilərsiniz");
                            return(View(homeDoctor));
                        }

                        if (homeDoctor.Upload.Length > 1048576)
                        {
                            ModelState.AddModelError("Upload", "Fayl ölcüsu maximum 1MB ola bilər");
                            return(View(homeDoctor));
                        }
                        var oldFile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "uploads", homeDoctor.Photo);
                        _fileManager.Delete(oldFile);

                        var fileName = _fileManager.Upload(homeDoctor.Upload, "wwwroot/uploads");
                        homeDoctor.Photo = fileName;
                    }


                    _context.Update(homeDoctor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HomeDoctorExsist(homeDoctor.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(homeDoctor));
        }