Exemplo n.º 1
0
 /// <summary>
 ///     创建 <see cref="UserController" />
 /// </summary>
 /// <param name="coupon">
 ///     <see cref="CouponProvider" />
 /// </param>
 /// <param name="owinContextProvider">
 ///     <see cref="OwinContextProvider" />
 /// </param>
 /// <param name="dbContext">
 ///     <see cref="KeylolDbContext" />
 /// </param>
 /// <param name="userManager">
 ///     <see cref="KeylolUserManager" />
 /// </param>
 /// <param name="oneTimeToken">
 ///     <see cref="OneTimeTokenProvider" />
 /// </param>
 /// <param name="roleManager"><see cref="KeylolRoleManager"/></param>
 public UserController(CouponProvider coupon, OwinContextProvider owinContextProvider, KeylolDbContext dbContext,
                       KeylolUserManager userManager, OneTimeTokenProvider oneTimeToken, KeylolRoleManager roleManager)
 {
     _coupon       = coupon;
     _owinContext  = owinContextProvider.Current;
     _dbContext    = dbContext;
     _userManager  = userManager;
     _oneTimeToken = oneTimeToken;
     _roleManager  = roleManager;
 }
Exemplo n.º 2
0
        public IHttpActionResult Post([FromBody] CartaoDTO cartao)
        {
            try
            {
                cartao.UsuarioId = Convert.ToInt32(OwinContextProvider.GetClaimValue("userId"));
                cartao           = _business.Insert(cartao);
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok(cartao));
        }
Exemplo n.º 3
0
        public IHttpActionResult Put([FromBody] EnderecoDTO endereco)
        {
            try
            {
                endereco.UsuarioId = Convert.ToInt32(OwinContextProvider.GetClaimValue("userId"));
                _business.Update(endereco);
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok());
        }
Exemplo n.º 4
0
        public IHttpActionResult GetAllFromUser()
        {
            List <CartaoDTO> cartoes = new List <CartaoDTO>();

            try
            {
                int userId = Convert.ToInt32(OwinContextProvider.GetClaimValue("userId"));
                cartoes = _business.GetAllFromUser(userId);
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok(cartoes));
        }
Exemplo n.º 5
0
        // GET: api/Produtos
        public IHttpActionResult GetAllFromUser(int page)
        {
            List <PedidoDTO> pedidos = new List <PedidoDTO>();

            try
            {
                int userId = Convert.ToInt32(OwinContextProvider.GetClaimValue("userId"));
                pedidos = _business.GetAllFromUser(userId, page);
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok(pedidos));
        }