Esempio n. 1
0
 public ActionResult Index(string searchString)
 {
     if (!String.IsNullOrEmpty(searchString))
     {
         return(View(_facultyRepository.SearchFaculty(searchString).ToList()));
     }
     return(View(_facultyRepository.GetAllFaculties().ToList()));
 }
Esempio n. 2
0
 public HttpResponseMessage GetAllFaculties()
 {
     try
     {
         List <FacultyModel> allFaculties = facultyRepository.GetAllFaculties();
         return(Request.CreateResponse(HttpStatusCode.OK, allFaculties));
     }
     catch (Exception ex)
     {
         Errors errors = ErrorsHelper.GetErrors(ex);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors));
     }
 }
 public IActionResult GetAllFaculties()
 {
     try
     {
         List <FacultyModel> allFaculties = facultyRepository.GetAllFaculties();
         return(Ok(allFaculties));
     }
     catch (Exception ex)
     {
         Errors errors = ErrorsHelper.GetErrors(ex);
         return(StatusCode(StatusCodes.Status500InternalServerError, errors));
     }
 }
        public JsonResult GetAllFaculties()
        {
            var faculties = repository.GetAllFaculties();

            if (faculties == null)
            {
                return(Json(null));
            }

            List <FacultyVM> view = new List <FacultyVM>();

            foreach (Faculty item in faculties)
            {
                view.Add(new FacultyVM(item));
            }

            return(Json(view));
        }
Esempio n. 5
0
 public HttpResponseMessage GetAllFaculties()
 {
     try
     {
         HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.OK)
         {
             Content = new StringContent(JsonConvert.SerializeObject(facultyRepository.GetAllFaculties()))
         };
         return(hrm);
     }
     catch (Exception ex)
     {
         Errors errors          = ErrorsHelper.GetErrors(ex);
         HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError)
         {
             Content = new StringContent(errors.ToString())
         };
         return(hr);
     }
 }
Esempio n. 6
0
 public IActionResult GetAll()
 {
     return(Ok(repository.GetAllFaculties()));
 }
Esempio n. 7
0
        public async Task <IEnumerable <FacultyResource> > GetAllFaculties()
        {
            var faculties = await repository.GetAllFaculties();

            return(mapper.Map <IEnumerable <Faculty>, IEnumerable <FacultyResource> >(faculties));
        }