public ActionResult EditSpecialty(EditSpecialty editSpecialty, HttpPostedFileBase image) { if (ModelState.IsValid) { SpecialtyDTO specialty = new SpecialtyDTO { Id = editSpecialty.Id, Number = editSpecialty.Number, Name = editSpecialty.Name, Description = editSpecialty.Description, FacultyId = editSpecialty.FacultyId, BudgetPlaces = editSpecialty.BudgetPlaces, TotalPlaces = editSpecialty.TotalPlaces }; if (image != null) { string filePath = "/Content/Image/Specialties/" + specialty.Name + Path.GetExtension(image.FileName); if (editSpecialty.Photo != null) { System.IO.File.Delete(Server.MapPath(filePath)); } image.SaveAs(Server.MapPath(filePath)); specialty.Photo = filePath; } else { specialty.Photo = editSpecialty.Photo; } _specialty.Update(specialty); } return(RedirectToAction("Specialties", new { facultyId = editSpecialty.FacultyId })); }
public ActionResult EditSpecialty(int id) { var specialty = _specialty.GetById(id); var editSpecialty = new EditSpecialty { Id = specialty.Id, Number = specialty.Number, Name = specialty.Name, Description = specialty.Description, Photo = specialty.Photo, FacultyId = specialty.FacultyId, BudgetPlaces = specialty.BudgetPlaces, TotalPlaces = specialty.TotalPlaces }; return(View(editSpecialty)); }