Beispiel #1
0
        public IActionResult Post([FromBody] WalletDTO dto)
        {
            var userId  = AuthMiddleware.GetUserId(User);
            var balance = _service.InsertMoney(dto, userId);

            return(Ok("Your current balance is: " + balance));
        }
Beispiel #2
0
        public IActionResult Delete()
        {
            var userId = AuthMiddleware.GetUserId(User);

            _service.DeleteById(userId);
            return(Ok("Your account is successfully deleted!"));
        }
Beispiel #3
0
        public IActionResult Get()
        {
            var userId = AuthMiddleware.GetUserId(User);
            var wallet = _service.GetById(userId);

            return(Ok("Your balance is: " + wallet.Amount));
        }
Beispiel #4
0
        public IActionResult Put([FromBody] UpdateUserDTO dto)
        {
            var userId = AuthMiddleware.GetUserId(User);

            _service.Update(dto, userId);
            return(Ok("Successfully updated!"));
        }
Beispiel #5
0
        public ActionResult <PageResponse <TransactionDTO> > Transactions([FromQuery] TransactionSearch search)
        {
            var userId       = AuthMiddleware.GetUserId(User);
            var transactions = _service.GetTransactions(search, userId);

            return(Ok(transactions));
        }
Beispiel #6
0
        public IActionResult Delete(int id)
        {
            var userId = AuthMiddleware.GetUserId(User);

            if (_service.CheckItemExist(userId, id))
            {
                _service.DeleteById(id);
                return(Ok("Successfully deleted!"));
            }

            return(BadRequest("Order with that id does not exist in your cart!"));
        }
Beispiel #7
0
        public IActionResult Submit()
        {
            var userId = AuthMiddleware.GetUserId(User);

            try
            {
                _service.Purchase(userId);
                return(Ok("Your order successfully purchased!"));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Beispiel #8
0
        public IActionResult Post([FromBody] InsertCartDTO dto)
        {
            var userId = AuthMiddleware.GetUserId(User);

            try
            {
                _service.Insert(dto, userId);
                return(Ok("Successfully added to cart!"));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Beispiel #9
0
        public ActionResult <CartDTO> Get()
        {
            var userId = AuthMiddleware.GetUserId(User);

            try
            {
                var items = _service.ListCart(userId);
                return(Ok(items));
            }
            catch (Exception e)
            {
                return(Ok(e.Message));
            }
        }
Beispiel #10
0
        public IActionResult Contact([FromBody] MailDTO dto)
        {
            var userId = AuthMiddleware.GetUserId(User);

            try
            {
                _service.SendMail(dto, userId);
                return(Ok("Mail sent!"));
            }
            catch (Exception e)
            {
                return(BadRequest("Something went wrong!"));
            }
        }
        public ActionResult <PageResponse <OrderDTO> > Get([FromQuery] OrderSearch search)
        {
            var userId = AuthMiddleware.GetUserId(User);

            search.UserId = userId;

            var orders = _service.Execute(search);

            if (orders == null)
            {
                return(Ok("You don't have any orders yet!"));
            }
            return(Ok(orders));
        }
Beispiel #12
0
        public IActionResult Put(int id, [FromBody] UpdateCartDTO dto)
        {
            var userId = AuthMiddleware.GetUserId(User);

            try
            {
                if (_service.CheckItemExist(userId, id))
                {
                    _service.Update(dto, id);
                    return(Ok("Quantity successfully updated!"));
                }
                return(BadRequest("Order with that id does not exist in your cart!"));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }