// GET: Faculty/Create public ActionResult Create() { try { FacultyController facultyController = new FacultyController(logger, _iconfiguration); ViewBag.ListFaculty = new Microsoft.AspNetCore.Mvc.Rendering.SelectList( ( from faculty in facultyController.FacultyModel select new SelectListItem { Text = faculty.Name, Value = faculty.FacultyId.ToString() } ) , "Value", "Text"); } catch (System.Net.Http.HttpRequestException ex) { _logger.LogCritical(ex.Message); _logger.LogCritical(ex.StackTrace); } catch (Exception ex) { _logger.LogCritical(ex.Message); _logger.LogCritical(ex.StackTrace); } return(View()); }
// GET: Faculty/Edit/5 public ActionResult Edit(short id) { //ViewData["Edit"] = _localizer["Edit"]; //ViewData["Person"] = _localizer["Person"]; //ViewData["Save"] = _localizer["Save"]; //ViewData["BackToList"] = _localizer["BackToList"]; FacultyController facultyController = new FacultyController(logger, _iconfiguration); WebFacultyService.FacultyDto facultyDto = null; try { ViewBag.ListFaculty = new Microsoft.AspNetCore.Mvc.Rendering.SelectList( ( from faculty in facultyController.FacultyModel select new SelectListItem { Text = faculty.Name, Value = faculty.FacultyId.ToString() } ) , "Value", "Text"); var url = _iconfiguration.GetValue <string>("WebServices:Faculty:WebFacultyService"); WebFacultyService.WebFacultyServiceSoapClient soapClient = new WebFacultyService.WebFacultyServiceSoapClient(new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(url)); facultyDto = soapClient.GetId(id); } catch (System.Net.Http.HttpRequestException ex) { _logger.LogCritical(ex.Message); _logger.LogCritical(ex.StackTrace); } catch (Exception ex) { _logger.LogCritical(ex.Message); _logger.LogCritical(ex.StackTrace); } FacultyModel facultyModel = new FacultyModel() { FacultyId = facultyDto.FacultyId, Deleted = facultyDto.Deleted, Name = facultyDto.Name }; return(View(facultyModel)); }