private string ProcessUploadFile(EmployeeCreateViewMoel model)
        {
            string uniqueFileName = null;

            if (model.Photo != null)
            {
                string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images");
                uniqueFileName = Guid.NewGuid().ToString() + "_" + model.Photo.FileName;
                string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    model.Photo.CopyTo(fileStream);
                }
            }
            return(uniqueFileName);
        }
 public IActionResult Create(EmployeeCreateViewMoel model)
 {
     if (ModelState.IsValid)
     {
         string   uniqueFileName = ProcessUploadFile(model);
         Employee newEmployee    = new Employee
         {
             Name       = model.Name,
             Email      = model.Email,
             Department = model.Department,
             PhotoPath  = uniqueFileName
         };
         _employeeRepository.Add(newEmployee);
         return(RedirectToAction("details", new { id = newEmployee.Id }));
     }
     return(View());
 }