public IHttpActionResult Save([FromBody] Enquiry enquiry) { try { enquiry.CreatedDate = DateTime.Now; _enquiry.Add(enquiry); var res = new ApiResponse() { status = HttpStatusCode.OK.ToString(), code = (int)HttpStatusCode.OK, result = _enquiry.List() }; return(Ok(res)); } catch (Exception) { return(BadRequest()); } }
public IHttpActionResult GetAll([System.Web.Http.FromUri] PagingModel pagingModel) { var lst = _faculty.List(); #region Paging int count = lst.Count(); int CurrentPage = pagingModel.pageNumber + 1; int PageSize = pagingModel.pageSize; int TotalCount = count; int TotalPages = (int)Math.Ceiling(count / (double)PageSize); // Returns List of Customer after applying Paging var items = lst.OrderBy(x => x.Id).Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToList(); // if CurrentPage is greater than 1 means it has previousPage var previousPage = CurrentPage > 1 ? "Yes" : "No"; // if TotalPages is greater than CurrentPage means it has nextPage var nextPage = CurrentPage < TotalPages ? "Yes" : "No"; var paginationMetadata = new { totalCount = TotalCount, pageSize = PageSize, currentPage = CurrentPage, totalPages = TotalPages, previousPage, nextPage }; #endregion if (items != null) { var res = new ApiResponse() { status = HttpStatusCode.OK.ToString(), code = (int)HttpStatusCode.OK, result = items, pages = count }; return(Ok(res)); } else { return(BadRequest()); } }
public IHttpActionResult GetHomeBanner() { var lst = _banner.List().ToList(); if (lst != null) { var res = new ApiResponse() { status = HttpStatusCode.OK.ToString(), code = (int)HttpStatusCode.OK, result = lst }; return(Ok(res)); } else { return(BadRequest()); } }
public IHttpActionResult GetAll([System.Web.Http.FromUri] PagingModel pagingModel) { //var lst = _admissionForm.List(); var lst = _admissionForm.List().ToList().ConvertAll(x => new StudentAdmissionFormResponse { registrationNumber = x.RegistrationNumber, submittedStatus = string.IsNullOrEmpty(x.SubmittedStatus)?"":"Submitted", id = x.Id, address = x.Address, candidatename = x.CandidateName, city = x.City, coursetype = x.CourseType, email = x.Email, fathername = x.FatherName, qualificationList = _studentMapping.List().Where(y => y.StudentAdmissionID == x.Id).ToList().ConvertAll(xy => new QualificationResp { boards = xy.Boards, sclass = xy.Boards, subjects = xy.Subjects, yearofpassing = xy.YearOfPassing, }).ToList(), mobile = x.Mobile, mothername = x.MotherName, state = x.State }).ToList(); #region Paging int count = lst.Count(); int CurrentPage = pagingModel.pageNumber + 1; int PageSize = pagingModel.pageSize; int TotalCount = count; int TotalPages = (int)Math.Ceiling(count / (double)PageSize); // Returns List of Customer after applying Paging var items = lst.OrderBy(x => x.id).Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToList(); // if CurrentPage is greater than 1 means it has previousPage var previousPage = CurrentPage > 1 ? "Yes" : "No"; // if TotalPages is greater than CurrentPage means it has nextPage var nextPage = CurrentPage < TotalPages ? "Yes" : "No"; var paginationMetadata = new { totalCount = TotalCount, pageSize = PageSize, currentPage = CurrentPage, totalPages = TotalPages, previousPage, nextPage }; #endregion if (items != null) { var res = new ApiResponse() { status = HttpStatusCode.OK.ToString(), code = (int)HttpStatusCode.OK, result = items, pages = count }; return(Ok(res)); } else { return(BadRequest()); } }