public IActionResult Edit(EmployeeEditViewModel model) { if (ModelState.IsValid) { EmployeeProp employeeProp = _employeeRepository.GetEmployeeId(model.id); employeeProp.Name = model.Name; employeeProp.Department = model.Department; employeeProp.Email = model.Email; if (model.Photo != null) { if (model.ExistingPhoto != null) { string filePath = Path.Combine(_hostingEnviroment.WebRootPath, "images", model.ExistingPhoto); System.IO.File.Delete(filePath); } employeeProp.photoPath = ProcessUploadFile(model); } _ = _employeeRepository.Update(employeeProp); return(RedirectToAction("Index")); } return(View(model)); }
public static void Display() { Person bob = new Person("Bob", "Robertson"); bob.Display(); // Bob Robertson Employee tom = new Employee("Tom", "Smith", "Microsoft"); tom.Display(); // Tom Smith работает в Microsoft PersonProp p = new PersonProp(); p.Name = "Ann"; EmployeeProp e = new EmployeeProp(); e.Name = "Mike"; Console.WriteLine($"{p.Name}"); Console.WriteLine($"{e.Name}"); ExampleBase exb = new ExampleBase(); Console.WriteLine($"x={exb.x} G={ExampleBase.G}"); ExampleDerived exd = new ExampleDerived(); Console.WriteLine($"x={exd.x} G={ExampleDerived.G}"); }
public ViewResult Edit(int id) { EmployeeProp employeeProp = _employeeRepository.GetEmployeeId(id); EmployeeEditViewModel employeeEditViewModel = new EmployeeEditViewModel { id = employeeProp.EMPId, Name = employeeProp.Name, Email = employeeProp.Email, Department = employeeProp.Department, ExistingPhoto = employeeProp.photoPath }; return(View(employeeEditViewModel)); }
public IActionResult Create(EmployeeCreateViewModel model) { if (ModelState.IsValid) { string uniqueFileName = ProcessUploadFile(model); EmployeeProp newEmploy = new EmployeeProp { Name = model.Name, Email = model.Email, Department = model.Department, photoPath = uniqueFileName }; _employeeRepository.Add(newEmploy); return(RedirectToAction("Details", new { id = newEmploy.EMPId })); } return(View()); }
public ViewResult Details(int?Id) { EmployeeProp employeeProp = _employeeRepository.GetEmployeeId(Id.Value); if (employeeProp == null) { Response.StatusCode = 404; return(View("EmployeeNotFound", Id.Value)); } HomeDetailsViewModel homeDetailsViewModel = new HomeDetailsViewModel() { employeeProp = employeeProp, PageTitle = "Employee Details" }; return(View(homeDetailsViewModel)); }