Exemplo n.º 1
0
        public RestfulResult Portrait(PortraitRequest request, int?authuid, UserModel authUser)
        {
            request.AuthUid  = authuid.Value;
            request.AuthUser = authUser;

            switch (request.Method.ToLower())
            {
            case DefineRestfulMethod.Create:
                var r = new UploadLogoRequest(request)
                {
                    Files = Request.Files
                };
                return(new RestfulResult {
                    Data = this._customerService.UploadLogo(r)
                });

            case DefineRestfulMethod.Destroy:
                var d = new DestroyLogoRequest(request);
                return(new RestfulResult {
                    Data = this._customerService.DestroyLogo(d)
                });
            }

            return(new RestfulResult {
                Data = new ExecuteResult {
                    StatusCode = StatusCode.ClientError, Message = "参数错误"
                }
            });
        }
Exemplo n.º 2
0
        public ExecuteResult <CustomerInfoResponse> DestroyLogo(DestroyLogoRequest request)
        {
            if (!request.Type.HasValue ||
                request.Type.Value == Hangzhou.Contract.DTO.ThumnImageType.Logo)
            {
                var oldResource = _resourceService.Get(request.AuthUser.Id, SourceType.CustomerPortrait);

                if (oldResource == null || oldResource.Count == 0)
                {
                    return(new ExecuteResult <CustomerInfoResponse>(null)
                    {
                        StatusCode = StatusCode.ClientError, Message = "您还没有上传过肖像"
                    });
                }

                foreach (var item in oldResource)
                {
                    _resourceService.Del(item.Id);
                }

                return(GetUserInfo(new GetUserInfoRequest
                {
                    AuthUid = request.AuthUser.Id,
                    AuthUser = null,
                    Method = null,
                    Token = null,
                    Client_Version = request.Client_Version
                }));
            }
            else
            {
                var oldResource = _resourceService.Get(request.AuthUser.Id, SourceType.CustomerThumbBackground).FirstOrDefault();
                if (oldResource != null)
                {
                    _resourceService.Del(oldResource.Id);
                }
                return(new ExecuteResult <CustomerInfoResponse>(null));
            }
        }