public static ShopInfoResponse Unmarshall(UnmarshallerContext context)
        {
            ShopInfoResponse shopInfoResponse = new ShopInfoResponse();

            shopInfoResponse.HttpResponse = context.HttpResponse;
            shopInfoResponse.Success      = context.BooleanValue("ShopInfo.Success");
            shopInfoResponse.Data         = context.StringValue("ShopInfo.Data");
            shopInfoResponse.ErrorCode    = context.IntegerValue("ShopInfo.ErrorCode");
            shopInfoResponse.ErrorMsg     = context.StringValue("ShopInfo.ErrorMsg");

            return(shopInfoResponse);
        }
Exemplo n.º 2
0
        public virtual async Task <ShopInfoResponse> FindByIdAsync(string userid, string id, CancellationToken cancellationToken = default(CancellationToken))
        {
            var query = _shopsStore.GetDetailQuery();

            query = query.Where(x => x.Id == id);

            var shops = await query.FirstOrDefaultAsync(cancellationToken);

            if (shops == null)
            {
                return(null);
            }

            ShopInfoResponse shopsResponse = _mapper.Map <ShopInfoResponse>(shops);

            shopsResponse.FileList       = new List <FileItemResponse>();
            shopsResponse.AttachmentList = new List <AttachmentResponse>();

            if (shops.ShopsFileInfos?.Count() > 0)
            {
                var f = shops.ShopsFileInfos.Select(a => a.FileGuid).Distinct();
                foreach (var item in f)
                {
                    var f1 = shops.ShopsFileInfos.Where(a => a.Type != "Attachment" && a.FileGuid == item).ToList();
                    if (f1?.Count > 0)
                    {
                        shopsResponse.FileList.Add(ConvertToFileItem(item, f1));
                    }
                    var f2 = shops.ShopsFileInfos.Where(a => a.Type == "Attachment" && a.FileGuid == item).ToList();
                    if (f2?.Count > 0)
                    {
                        shopsResponse.AttachmentList.AddRange(ConvertToAttachmentItem(f2));
                    }
                }
            }
            shopsResponse.IsFavorite = await _ishopsFavoriteStore.GetAsync(x => x.Where(y => y.UserId == userid && y.ShopsId == shopsResponse.Id && !y.IsDeleted)) == null ? false : true;

            return(shopsResponse);
        }