public IActionResult Create(int?id) { ViewData["DepartmentId"] = new SelectList(_departmentRepository.GetAll(), "Id", "Name"); ViewData["SemesterId"] = new SelectList(_semesterRepository.GetAllSemester(), "Id", "Name"); ViewBag.Image = ""; if (id != null) { var dbId = Convert.ToInt32(id); var entity = _repository.GetById(dbId); if (entity != null) { try { var base64 = ByteArrayToImage(entity.Image); ViewBag.Image = "data:image/gif;base64," + base64; } catch (Exception) { //iggnor } return(View(entity)); } } return(View()); }
public ActionResult Index() { var entities = _semesterRepository.GetAllSemester(); return(View(entities)); }