public ServiceResponseWithResultset <StudentModel> Search(Search_StudentRequest request) { try { var result = this._context.proc_Student_GetAll(request.FirstName, request.LastName, request.GenderId, request.StudentCode, request.CityId, request.PageIndex, request.PageSize.Equals(0) ? 10 : request.PageSize, request.SortColumn, "ASC").ToList(); List <StudentModel> collection = new List <StudentModel>(); var totalRecords = result.First().TotalRecord; foreach (var item in result) { collection.Add(new StudentModel { FirstName = item.firstName, MiddleName = item.middleName, LastName = item.lastName, StudentId = item.studentId, IsReadyToNextYear = item.IsReadyToNextYear == 1?true:false, StudentCode = this.GetStudentNumber(item.studentId), GenderModel = new GenderModel { GenderDescription = item.GenderDescription, GenderId = item.genderId }, CityModel = new CityModel { CityDescription = item.CityDescription, CityId = item.cityId.HasValue?item.cityId.Value:0 } }); } return(new ServiceResponseWithResultset <StudentModel> { Response = Model.Enumerator.Enum.ServiceResponses.Success, Reason = "OK", Data = collection, TotalRecords = totalRecords }); } catch (Exception ex) { return(new ServiceResponseWithResultset <StudentModel> { Response = Model.Enumerator.Enum.ServiceResponses.Failure, Reason = "Error on Search method. " + ex.InnerException != null ? ex.InnerException.Message : ex.Message }); } }
public JsonResult GetAll(Search_StudentRequest request) { var result = _studentRepository.Search(request); if (result.Response == Model.Enumerator.Enum.ServiceResponses.Success) { return(Json(new { status = "OK", aaData = result.Data, iTotalRecords = result.TotalRecords, iTotalDisplayRecords = result.TotalRecords }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { status = "ERROR", message = result.Reason }, JsonRequestBehavior.AllowGet)); } }
public ServiceResponseWithResultset <PeriodGradeStudentModel> GetAll(Search_StudentRequest request) { //throw new NotImplementedException(); try { var result = this._context.proc_Grade_StudentDetailByPeriod(request.PeriodId, request.GradeId, request.FirstName, request.LastName, request.GenderId, request.StudentCode, request.PageIndex, request.PageSize.Equals(0)?10: request.PageSize, request.SortColumn, "ASC").ToList(); List <PeriodGradeStudentModel> collection = new List <PeriodGradeStudentModel>(); var totalRecords = result.First().TotalRecord; foreach (var item in result) { collection.Add(new PeriodGradeStudentModel { PeriodGradeStudentId = item.periodGradeStudentId, StudentModel = new StudentModel { FirstName = item.firstName, MiddleName = item.middleName, LastName = item.lastName, StudentId = item.studentId, StudentCode = "123456", GenderModel = new GenderModel { GenderDescription = item.genderDescription, GenderLetter = item.genderLetter, GenderId = item.genderId }, IsReadyToNextYear = item.IsReadyToNextYear == 0?false:true }, PeriodGradeGroupModel = new PeriodGradeGroupModel { GroupDescription = "01", PeriodGradeGroupId = 1, PeriodGradeModel = new PeriodGradeModel { PeriodGradeId = item.periodGradeId, GradeModel = new GradeModel { GradeDescription = item.gradeDescription, GradeId = item.gradeId }, PeriodModel = new PeriodModel { Active = true, PeriodId = item.periodId, YearDescription = item.YearDescription, YearFrom = item.YearFrom, YearTo = item.YearTo } } } }); } return(new ServiceResponseWithResultset <PeriodGradeStudentModel> { Response = Model.Enumerator.Enum.ServiceResponses.Success, Reason = "OK", Data = collection, TotalRecords = totalRecords }); } catch (Exception ex) { return(new ServiceResponseWithResultset <PeriodGradeStudentModel> { Response = Model.Enumerator.Enum.ServiceResponses.Failure, Reason = "Error on GetAll method. " + ex.InnerException != null ? ex.InnerException.Message : ex.Message }); } }