public IActionResult PromocodeDetail(GetPromoCodeDetailModel promoCodeDetailModel) { try { if (ModelState.IsValid) { var promocodeDetail = iPromoCode.GetPromocodeDetail(DBHelper.ParseInt64(promoCodeDetailModel.promoCodeId)); if (promocodeDetail != null) { PromoCodeDataListModel promoCodeListModel = PromoCodeHelper.BindPromoCodeListModel(promocodeDetail); return(Ok(ResponseHelper.Success(promoCodeListModel))); } else { return(Ok(ResponseHelper.Error(MessageConstants.DataNotFound))); } } else { return(Ok(ResponseHelper.Error(MessageConstants.DataNotFound))); } } catch (Exception ex) { LogHelper.ExceptionLog(ex.Message + " ::::: " + ex.StackTrace); return(Ok(ResponseHelper.Error(ex.Message))); } }
public IActionResult PromocodeList(SearchPaginationListModel searchModel) { try { if (searchModel.pageNo <= 0) { searchModel.pageNo = 1; } var promoCodeList = iPromoCode.GetPromocodeList(searchModel.searchString); if (promoCodeList != null) { PromoCodeListModel promoCodeListModel = new PromoCodeListModel(); List <PromoCode> promoCodePagedresult = new List <PromoCode>(); promoCodePagedresult = promoCodeList.OrderByDescending(x => x.PromoCodeId).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); #region Sorting if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.promocodeid)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.asc))) { promoCodePagedresult = promoCodeList.OrderBy(x => x.PromoCodeId).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.promocodeid)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.desc))) { promoCodePagedresult = promoCodeList.OrderByDescending(x => x.PromoCodeId).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.name)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.asc))) { promoCodePagedresult = promoCodeList.OrderBy(x => x.Name).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.name)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.desc))) { promoCodePagedresult = promoCodeList.OrderByDescending(x => x.Name).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.code)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.asc))) { promoCodePagedresult = promoCodeList.OrderBy(x => x.Code).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.code)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.desc))) { promoCodePagedresult = promoCodeList.OrderByDescending(x => x.Code).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.startdate)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.asc))) { promoCodePagedresult = promoCodeList.OrderBy(x => x.StartDate).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.startdate)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.desc))) { promoCodePagedresult = promoCodeList.OrderByDescending(x => x.StartDate).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.expirydate)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.asc))) { promoCodePagedresult = promoCodeList.OrderBy(x => x.ExpiryDate).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.expirydate)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.desc))) { promoCodePagedresult = promoCodeList.OrderByDescending(x => x.ExpiryDate).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.discount)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.asc))) { promoCodePagedresult = promoCodeList.OrderBy(x => x.Amount).ThenBy(x => x.Percentage).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else if (searchModel.column.ToLower().Equals(DBHelper.ParseString(SortingPromocodeColumnName.discount)) && searchModel.direction.ToLower().Equals(DBHelper.ParseString(SortingDirectionType.desc))) { promoCodePagedresult = promoCodeList.OrderByDescending(x => x.Amount).ThenByDescending(x => x.Percentage).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } else { promoCodePagedresult = promoCodeList.OrderBy(x => x.PromoCodeId).ToPagedList(searchModel.pageNo, searchModel.limit).ToList(); } #endregion List <PromoCodeDataListModel> promoCodeDataListModel = PromoCodeHelper.BindPromoCodeListModel(promoCodePagedresult); //promoCodeListModel.Total =DBHelper.ParseString(iPromoCode.GetTotalPromocodeCount()); promoCodeListModel.Total = DBHelper.ParseString(promoCodeList.Count); promoCodeListModel.Items = promoCodeDataListModel; return(Ok(ResponseHelper.Success(promoCodeListModel))); } else { return(Ok(ResponseHelper.Error(MessageConstants.DataNotFound))); } } catch (Exception ex) { LogHelper.ExceptionLog(ex.Message + " ::::: " + ex.StackTrace); return(Ok(ResponseHelper.Error(ex.Message))); } }