public ExecuteResult<HotWordCollectionResponse> GetCollection() { var response = new HotWordCollectionResponse(); var groupEntities = _repository.Get(v => v.Status == (int)DataStatus.Normal).Select(v => new { v.Word, v.Type, v.SortOrder }).GroupBy(v => v.Type).ToList(); var words = groupEntities.Where(v => v.Key == (int)HotWordType.Words).ToList(); var brands = groupEntities.Where(v => v.Key == (int)HotWordType.BrandStruct).ToList(); if (words.Count > 0) { var t = words[0].OrderByDescending(v => v.SortOrder).Select(v => v.Word).ToList(); response.Words = t; } if (brands.Count > 0) { var t = brands[0].OrderByDescending(v => v.SortOrder).Select(v => JsonExtension.FromJson<BrandWordsInfo>(v.Word)).ToList(); if (t.Count > 0) { response.BrandWords = t; } } var result = new ExecuteResult<HotWordCollectionResponse> { Data = response }; return result; }
protected ActionResult RestfulResult(ExecuteResult data) { return new RestfulResult { Data = data }; }
public ExecuteResult<ItemsCollectionResponse> GetProductList(GetItemsListRequest request) { var r = Get(request.Version, request.PagerRequest, request.Timestamp, request.UserModel.Id); var result = new ExecuteResult<ItemsCollectionResponse> { Data = r }; return result; }
/// <summary> /// 获取店铺信息 /// </summary> /// <param name="request"></param> /// <returns></returns> public ExecuteResult<StoreInfoResponse> GetStore(StoreRequest request) { var entity = _storeRepsitory.GetItem(request.StoreId); var response = MappingManager.StoreResponseMapping(entity); var result = new ExecuteResult<StoreInfoResponse> { Data = response }; return result; }
public ExecuteResult<SpecialTopicInfoResponse> GetInfo(GetSpecialTopicInfoRequest request) { var data = _specialTopicRepository.GetItem(request.TopicId); var response = MappingManager.SpecialTopicInfoResponseMapping(data); var result = new ExecuteResult<SpecialTopicInfoResponse>(response); return result; }
public ExecuteResult<CommentCollectionResponse> GetList(CommentListRequest request) { int totalCount; var data = this._commentRepository.GetPagedList(request.PagerRequest.PageIndex, request.PagerRequest.PageSize, out totalCount, request.SortOrder, request.Timestamp, request.SourceId, request.SType); var result = new ExecuteResult<CommentCollectionResponse>(); var response = new CommentCollectionResponse(request.PagerRequest, totalCount) { Comments = MappingManager.CommentInfoResponseMapping(data, request.Version).ToList() }; result.Data = response; return result; }
public ExecuteResult<PromotionCollectionResponse> GetPromotionForBanner(GetPromotionBannerListRequest request) { var page = new PagerRequest(request.Page, request.Pagesize, 40); int totalCount; var entities = _promotionRepository.Get(page, out totalCount, request.SortOrder, null, PromotionFilterMode.NotTheEnd, DataStatus.Normal, true); var response = new PromotionCollectionResponse(page, totalCount) { Promotions = MappingManager.PromotionResponseMapping(entities, request.CoordinateInfo, true) }; var result = new ExecuteResult<PromotionCollectionResponse> { Data = response }; return result; }
private ExecuteResult<SpecialTopicCollectionResponse> Get(PagerRequest pagerRequest, SpecialTopicSortOrder sortOrder, Timestamp timestamp) { int totalCount; var data = _specialTopicRepository.GetPagedList(pagerRequest, out totalCount, sortOrder, timestamp); var response = new SpecialTopicCollectionResponse(pagerRequest, totalCount) { SpecialTopics = MappingManager.SpecialTopicInfoResponseMapping(data).ToList() }; var result = new ExecuteResult<SpecialTopicCollectionResponse> { Data = response }; return result; }
/// <summary> /// 记录asp.net未捕获的异常 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void OnError(object sender, EventArgs e) { HttpContext context = HttpContext.Current; if (context == null) return; var exception = context.Server.GetLastError(); if (exception == null) return; string message = exception.Message; var httpException = exception as HttpException; int statusCode = 404; if (httpException != null) { statusCode = httpException.GetHttpCode(); } //包括记录异常的内部包含异常 while (exception != null) { _log.Error("Global:"); _log.Error(exception); exception = exception.InnerException; } context.Server.ClearError(); context.Response.TrySkipIisCustomErrors = true; //输出错误信息 var format = context.Request[Define.Format]; if (String.IsNullOrEmpty(format)) { format = String.Empty; // 如果为空,将会使用默认值 } var response = String.Empty; var result = new ExecuteResult() { Message = "服务器正在维护请稍后重试!", StatusCode = StatusCode.InternalServerError }; switch (format.ToLower()) { case Define.Json: response = Utils.DataContractToJson(result); context.Response.ContentType = "application/json; charset=utf-8"; break; case Define.Xml: response = result.ToXml(); context.Response.ContentType = "text/xml; charset=utf-8"; break; default: response = Utils.DataContractToJson(result); context.Response.ContentType = "text/html; charset=utf-8"; break; } context.Response.ClearHeaders(); context.Response.Clear(); context.Response.StatusCode = 200; context.Response.Write(response); }
/// <summary> /// 获取产品列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public ExecuteResult<ProductCollectionResponse> GetProductList(GetProductListRequest request) { if (request == null) { return new ExecuteResult<ProductCollectionResponse>(null) { StatusCode = StatusCode.ClientError, Message = "参数错误" }; } int? ruserId; List<int> tagIds = null; if (request.TagId != null) { tagIds = new List<int> { request.TagId.Value }; } if (request.UserModel == null) { ruserId = null; } else { ruserId = request.UserModel.Id; } var filter = new ProductFilter { BrandId = request.BrandId, DataStatus = DataStatus.Normal, ProductName = null, RecommendUser = ruserId, TagIds = tagIds, Timestamp = request.Timestamp, TopicId = request.TopicId, PromotionId = request.PromotionId }; ProductCollectionResponse r; int totalCount; if (request.Version > 2.09) { var produtEntities = _productRepository.Get(request.PagerRequest, out totalCount, request.ProductSortOrder, filter); var response = new ProductCollectionResponse(request.PagerRequest, totalCount) { Products = MappingManager.ProductInfoResponseMapping(produtEntities).ToList() }; r = response; } else { var p = _productRepository.GetPagedList(request.PagerRequest, out totalCount, request.ProductSortOrder, filter); var response = new ProductCollectionResponse(request.PagerRequest, totalCount) { Products = MappingManager.ProductInfoResponseMapping(p).ToList() }; r = response; } var result = new ExecuteResult<ProductCollectionResponse> { Data = r }; return result; }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="okMessage"></param> /// <returns></returns> private ExecuteResult<CardInfoResponse> GetInfo(GetCardInfoRequest request, string okMessage) { if (request == null || request.AuthUser == null) { return new ExecuteResult<CardInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "参数错误" }; } var entities = _cardRepository.GetListForUserId(request.AuthUser.Id, CardType.YintaiMemberCard, DataStatus.Normal).ToList(); if (entities.Count == 0) { return new ExecuteResult<CardInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "你还没有绑定会员卡,请您先绑定" }; } if (entities.Count > 1) { return new ExecuteResult<CardInfoResponse>(null) { StatusCode = StatusCode.InternalServerError, Message = "服务器开小差了,请您等等再试" }; } var entity = entities[0]; var pointResult = _groupCardService.GetPoint(new GroupCardPointRequest { CardNo = entity.CardNo }); var cardProfile = JsonExtension.FromJson_<CardProfile>(entity.CardProfile); if (pointResult.Success) { var response = new CardInfoResponse { Point = pointResult.Point, CardLvl = cardProfile.Lvl, CardNo = entity.CardNo, CardType = cardProfile.Type, User_Id = entity.User_Id, LastDate = DateTime.Now, Id = entity.Id }; var result = new ExecuteResult<CardInfoResponse>(response); if (!String.IsNullOrEmpty(okMessage)) { result.Message = okMessage; } return result; } return new ExecuteResult<CardInfoResponse>(null) { StatusCode = StatusCode.InternalServerError, Message = String.Concat("查询积点失败,", pointResult.Desc) }; }
public ExecuteResult<CouponInfoCollectionResponse> GetList(CouponInfoGetListRequest request) { if (request == null) { return new ExecuteResult<CouponInfoCollectionResponse>(null) { StatusCode = StatusCode.ClientError, Message = "参数错误" }; } int totalCount; var datas = this._couponRepository.GetPagedListByUserId(request.PagerRequest, out totalCount, request.AuthUid, request.CouponSortOrder); var response = new CouponInfoCollectionResponse(request.PagerRequest, totalCount) { CouponInfoResponses = MappingManager.CouponInfoResponseMapping(datas).ToList() }; var result = new ExecuteResult<CouponInfoCollectionResponse>(response); return result; }
/// <summary> /// 获取促销详情信息 /// </summary> /// <param name="request"></param> /// <returns></returns> public ExecuteResult<PromotionInfoResponse> GetPromotionInfo(GetPromotionInfoRequest request) { var entity = _promotionRepository.GetItem(request.Promotionid); var response = MappingManager.PromotionResponseMapping(entity, request.CoordinateInfo); if (request.CurrentAuthUser != null && response != null) { //是否收藏 response = IsR(response, request.CurrentAuthUser, response.Id); } var result = new ExecuteResult<PromotionInfoResponse>(response); return result; }
/// <summary> /// 刷新接口 /// </summary> /// <param name="request"></param> /// <returns></returns> public ExecuteResult<PromotionCollectionResponse> GetPromotionListForRefresh(GetPromotionListForRefresh request) { var timestamp = new Timestamp { TsType = TimestampType.New, Ts = DateTime.Parse(request.RefreshTs) }; var response = GetList(request.PagerRequest, timestamp, request.SortOrder, request.CoordinateInfo); var result = new ExecuteResult<PromotionCollectionResponse> { Data = response }; return result; }
/// <summary> /// 获取会员信息 /// </summary> /// <param name="request"></param> /// <returns></returns> public ExecuteResult<CustomerInfoResponse> GetUserInfo(GetUserInfoRequest request) { var userModel = GetUser(request.AuthUid); if (userModel == null) { return new ExecuteResult<CustomerInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "获取用户信息失败" }; } var result = new ExecuteResult<CustomerInfoResponse>(); var response = MappingManager.CustomerInfoResponseMappingForReadCount(userModel); result.Data = response; return result; }