public async Task <IActionResult> PutTickets([FromBody] LotterySale order)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            string email = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
            var    user  = await _userHelper.GetUserByEmailAsync(email);

            if (user == null)
            {
                return(NotFound("Error001"));
            }

            //Order currentOrder = await _context.Orders
            //    .Include(o => o.User)
            //    .ThenInclude(u => u.City)
            //    .Include(o => o.OrderDetails)
            //    .ThenInclude(od => od.Product)
            //    .ThenInclude(od => od.Category)
            //    .Include(o => o.OrderDetails)
            //    .ThenInclude(od => od.Product)
            //    .ThenInclude(od => od.ProductImages)
            //    .FirstOrDefaultAsync(o => o.Id == order.Id && o.User.Id == user.Id);
            //if (currentOrder == null)
            //{
            //    return NotFound();
            //}

            //currentOrder.OrderStatus = order.OrderStatus;
            //currentOrder.Remarks = order.Remarks;
            //_context.Orders.Update(currentOrder);
            await _context.SaveChangesAsync();

            return(Ok());// (currentOrder);
        }
Example #2
0
        public async Task <IActionResult> SaveSales([FromBody] LotterySale sell) //LotterySale sell.LotterySale, List<LotterySaleItem> items)
        {
            bool status  = false;
            long idi     = 0;
            var  msg     = string.Empty;
            var  openUrl = "";

            if (!ModelState.IsValid)
            {
                return(new JsonResult(new { status, idi, msg = "Modelo Invalido" }));
            }

            var userId = await GetUserAsync();

            var response = await _repository.SaveSale(sell, MyCurrentUser.Get.OwnerId, userId);

            if (!response.IsSuccess)
            {
                return(new JsonResult(new { status, idi, msg = response.Message }));
            }

            try
            {
                status = true;
                idi    = sell.Id;

                openUrl = Url.Action("PrintTicket", new { id = idi });
            }
            catch (Exception ex)
            {
                msg    = ex.Message;
                status = false;
            }

            return(new JsonResult(new { status, idi, msg, openUrl }));
        }