public async Task <IActionResult> Create([FromForm] SellBillCreateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var sellBill = await _sellService.CreateSellBill(request);

            return(Ok(sellBill));
        }
        public async Task <IActionResult> Index([FromForm] SellBillCreateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(View(request));
            }

            var result = await _sellApiClient.Create(request);

            if (result)
            {
                TempData["result"] = "Thêm mới sản phẩm thành công";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Thêm sản phẩm thất bại");


            return(View(request));
        }
        public async Task <int> CreateSellBill(SellBillCreateRequest request)
        {
            var sellBill = new SellBill()
            {
                Id            = request.SellBillId,
                CustomerId    = request.CustomerId,
                DateCreated   = DateTime.Now,
                UserCreated   = request.UserCreated,
                OriginalPrice = request.OriginalPrice,
                Discout       = request.Discout,
                TotalPrice    = request.TotalPrice,
                Pay           = request.Pay,
                PayBack       = request.PayBack,
                Note          = request.Note
            };

            _context.Bills.Add(sellBill);

            return(await _context.SaveChangesAsync());
        }
        public async Task <bool> Create(SellBillCreateRequest request)
        {
            var client = _httpClientFactory.CreateClient();

            client.BaseAddress = new Uri("https://localhost:5001");

            var requestContent = new MultipartFormDataContent();

            requestContent.Add(new StringContent(request.SellBillId.ToString()), "SellBillId");
            requestContent.Add(new StringContent(request.CustomerId.ToString()), "CustomerId");
            requestContent.Add(new StringContent(request.DateCreated.ToString()), "DateCreated");
            requestContent.Add(new StringContent(request.UserCreated.ToString()), "UserCreated");
            requestContent.Add(new StringContent(request.OriginalPrice.ToString()), "OriginalPrice");
            requestContent.Add(new StringContent(request.Discout.ToString()), "Discout");
            requestContent.Add(new StringContent(request.TotalPrice.ToString()), "TotalPrice");
            requestContent.Add(new StringContent(request.Note.ToString()), "Note");

            var response = await client.PostAsync("/api/Sell/create/", requestContent);

            return(response.IsSuccessStatusCode);
        }