public IHttpActionResult GetAll([System.Web.Http.FromUri] PagingModel pagingModel) { // var UserId= Request.Headers. var result = Request.Headers.FirstOrDefault(x => x.Key == "UserId").Value.FirstOrDefault(); if (result != null) { int userId = Convert.ToInt32(result); var lst = _genericRepository.Get(x => x.UserId == userId); #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, extra = lst.Sum(x => x.Hours) }; return(Ok(res)); } else { return(BadRequest()); } } else { throw new System.Exception("Invalid user"); } }
public IAspect <TIn, TOut> Get(object parameter) { var types = _arguments(parameter).Open().Append(Types.Open()).ToArray(); var result = _generic.Get(types)(parameter); return(result); }
IAllowedValueSpecification From(MemberDescriptor descriptor) { var result = IsCollectionTypeSpecification.Default.IsSatisfiedBy(descriptor.MemberType) ? new AllowedValueSpecification(_generic .Get(_type.Get(descriptor.MemberType)) .Invoke(_allowed)) : _allowed; return(result); }
public IHttpActionResult GetCourseBanner() { var lst = _banner.Get(x => x.Type == (int)BanneType.course).ToList(); if (lst != null) { var res = new ApiResponse() { status = HttpStatusCode.OK.ToString(), code = (int)HttpStatusCode.OK, result = lst }; return(Ok(res)); } else { return(BadRequest()); } }
protected override IDictionary Create(object parameter) { var pair = _locator.Get(parameter.GetType()); var result = pair.HasValue ? _dictionaries.Get(pair.Value.KeyType, pair.Value.ValueType)(parameter) : throw new InvalidOperationException($"Could not locate dictionary from type {parameter.GetType()}."); return(result); }
IAllowedValueSpecification FromDefault(TypeInfo reflectedType, MemberDescriptor parameter) { var defaultValue = _defaults.Get(reflectedType) .Invoke(parameter.Metadata); var specification = IsCollectionTypeSpecification.Default.IsSatisfiedBy(parameter.MemberType) ? _generic.Get(CollectionItemTypeLocator.Default.Get(parameter.MemberType)) .Invoke(defaultValue) : new EqualitySpecification <object>(defaultValue); var result = new AllowedValueSpecification(specification.Inverse()); return(result); }
public IHttpActionResult get(int id) { //var lst = _admissionForm.List(); var dom = new StudentAdmissionFormResponse(); var x = _admissionForm.GetById(id); dom = 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.Get(d => d.StudentAdmissionID == id).ToList().ConvertAll(xy => new QualificationResp { boards = xy.Boards, sclass = xy.Class, subjects = xy.Subjects, yearofpassing = xy.YearOfPassing, }).ToList(), mobile = x.Mobile, mothername = x.MotherName, state = x.State }; if (dom != null) { var res = new ApiResponse() { status = HttpStatusCode.OK.ToString(), code = (int)HttpStatusCode.OK, result = dom, pages = 0 }; return(Ok(res)); } else { return(BadRequest()); } }
public IHttpActionResult Login([FromBody] AdminUser user) { var dom = _genericRepository.Get(x => x.Email == user.Email && x.Password == user.Password).FirstOrDefault(); if (dom != null) { var res = new ApiResponse() { status = HttpStatusCode.OK.ToString(), code = (int)HttpStatusCode.OK, result = dom }; return(Ok(res)); } else { return(BadRequest()); } }
public IHttpActionResult Login([System.Web.Http.FromUri] UserMaster user) { var dom = _genericRepository.Get(x => x.Email == user.Email && x.Password == user.Password).FirstOrDefault(); if (dom != null) { var res = new ApiResponse() { status = HttpStatusCode.OK.ToString(), code = (int)HttpStatusCode.OK, result = dom }; return(Ok(res)); } else { throw new System.Exception("Details you have provided its not valid"); } }
public List <TModel> Get([FromQuery] TSearchRequest request) { return(_service.Get(request)); }