示例#1
0
        public async Task <IHttpActionResult> Create(SaleModel sale)
        {
            SaleDTO targetSale = mapper.Map <SaleModel, SaleDTO>(sale);
            await saleService.CreateSale(targetSale);

            return(Ok(new ResponseSheme(null, "Ok", 200)));
        }
示例#2
0
 public async Task <IActionResult> Add([FromBody] Sale model)
 {
     if (User.Identity.IsAuthenticated)
     {
         model.ApplicationUserId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(await _service.CreateSale(model, User.Identity.Name)));
     }
     return(Ok(false));
 }
        public async Task <IActionResult> Create(int id, SaleViewModel model)
        {
            try
            {
                var entity = _mapper.Map <Sale>(model);
                await _saleService.CreateSale(entity);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(model));
            }
        }
示例#4
0
        public async Task Checkout()
        {
            // Create SaleModel
            var sale = new SaleModel();

            foreach (var item in Cart)
            {
                sale.SaleDetails.Add(new SaleDetailModel
                {
                    ProductId = item.Product.Id,
                    Quantity  = item.Quantity
                });
            }

            // POST to API
            var saleId = await _saleService.CreateSale(sale);

            // TODO: What happens next?
            var x = saleId;

            // Reset Cart
            await ResetSalesViewModel();
        }
        public async Task <IActionResult> Create(CreateSaleDTO sale)
        {
            var createSale = await _saleService.CreateSale(sale);

            return(await ResponseAsync(createSale));
        }