Example #1
0
 private object ToBonusRecordViewModel(account_record b)
 {
     return(new
     {
         user_name = b.user.user_name,
         user_phone = b.user.user_phone,
         acc_type = AccountConstants.ToString(b.acc_type),
         bonus_money = b.cons_value,
         bonus_time = b.acc_record_time.ToString("yyyy-MM-dd HH:mm:ss"),
         bonus_remark = b.acc_remark,
         acc_balance = b.acc_balance
     });
 }
Example #2
0
        public async Task <AmigoEditViewModel> GetAmigoEditAsync(int id)
        {
            var amigo = await GetAmigoAsync(id);

            return(new AmigoEditViewModel
            {
                Id = amigo.Id,
                Nome = amigo.Nome,
                UserName = amigo.UserName,
                Telefone = amigo.Telefone,
                Email = amigo.Email,
                Status = AccountConstants.GetStatusUsuario(amigo.Status)
            });
        }
Example #3
0
        public async Task <IList <AmigoIndexViewModel> > ListAmigoAsync([FromQuery] AmigoFilterViewModel filter)
        {
            var listAmigo = new List <AmigoIndexViewModel>();

            RestClient  client  = new RestClient(_myGamesAPIConfig.URL);
            RestRequest request = new RestRequest("api/amigo", Method.GET);

            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            //System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;

            IRestResponse <List <AmigoResult> > response = await client.ExecuteAsync <List <AmigoResult> >(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var result = response.Data;

                if (!string.IsNullOrEmpty(filter.Nome))
                {
                    result = result.Where(x => x.Nome.ToUpper().Contains(filter.Nome.ToUpper())).ToList();
                }

                if (filter.Status.HasValue)
                {
                    result = result.Where(x => x.Status == filter.Status).ToList();
                }

                listAmigo = result.Select(x =>
                                          new AmigoIndexViewModel
                {
                    Id              = x.Id,
                    Nome            = x.Nome,
                    Telefone        = x.Telefone,
                    Email           = x.Email,
                    JogoEmpresatado = x.JogoEmprestado,
                    Status          = AccountConstants.GetStatusUsuario(x.Status)
                }).ToList();
            }

            return(listAmigo);
        }
Example #4
0
        public async Task <AmigoDeleteViewModel> GetAmigoDeleteAsync(int id)
        {
            var amigo = await GetAmigoAsync(id);

            return(new AmigoDeleteViewModel
            {
                Id = amigo.Id,
                Nome = amigo.Nome,
                UserName = amigo.UserName,
                Telefone = amigo.Telefone,
                Email = amigo.Email,
                Status = AccountConstants.GetStatusUsuario(amigo.Status),
                Historico = amigo.HistoricoEmprestimo.Where(x => x.Devolvido == false).Select(x =>
                                                                                              new HistoricoEmprestimoViewModel
                {
                    Nome = x.Nome,
                    TipoJogo = x.TipoJogo,
                    DtEmprestimo = x.DtEmprestimo.ToShortDateString(),
                    DtDevolucao = x.DtDevolucao.HasValue ? x.DtDevolucao.Value.ToShortDateString() : null
                }).ToList()
            });
        }