public async Task <IActionResult> Upload(AppoinmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                bool exists = _db.AppoinmentLetters.Any(p => p.Username == model.Username);
                if (exists)
                {
                    ViewBag.Username = new SelectList(_userManager.Users, "UserName", "UserName", model.Username);
                    ModelState.AddModelError(string.Empty, "Appoinment letter already exists for this user.");
                    return(View(model));
                }

                string uniqueFiles = UploadedFile(model);

                AppoinmentLetter appoinment = new AppoinmentLetter
                {
                    CreatedBy   = User.Identity.Name,
                    CreatedDate = DateTime.Now,
                    Username    = model.Username,

                    URL = uniqueFiles
                };

                _db.AppoinmentLetters.Add(appoinment);

                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.Username = new SelectList(_userManager.Users, "UserName", "UserName", model.Username);

            return(View(model));
        }
        public async Task <ActionResult> DeleteConfirmedAssort(int id)
        {
            AppoinmentLetter appoinmentLetter = await _db.AppoinmentLetters.FindAsync(id);

            string filePath = Path.Combine(_webHostEnvironment.WebRootPath, "appoinmentletter/", appoinmentLetter.URL);

            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.Delete(filePath);
            }

            _db.AppoinmentLetters.Remove(appoinmentLetter);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }