예제 #1
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction(nameof(Error), new { message = "Id not provided" }));
            }

            SalesRecord saleRecord = await _salesRecordService.FindByIdAsync(id.Value);

            if (saleRecord == null)
            {
                return(RedirectToAction(nameof(Error), new { message = "Id not found" }));
            }

            List <Seller> list = await _sellerService.FindAllAsync();

            SaleRecordViewModel viewModel = new SaleRecordViewModel {
                Seller = list, SalesRecord = saleRecord
            };

            return(View(viewModel));
        }
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction(nameof(Error), new { message = "Id not provided" }));
            }

            var obj = await _salesRecordService.FindByIdAsync(id.Value);

            if (obj == null)
            {
                return(RedirectToAction(nameof(Error), new { message = "Id not found" }));
            }

            List <Seller> sellers = await _sellerService.FindAllAsync();

            SalesFormViewModel viewModel = new SalesFormViewModel
            {
                SalesRecord = obj,
                Sellers     = sellers
            };

            return(View(viewModel));
        }
예제 #3
0
        // GET: SalesRecords/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var obj = await _salesRecordService.FindByIdAsync(id.Value);

            var salesRecord = await _context.Seller.FirstOrDefaultAsync(m => m.Id == id);

            if (obj == null)
            {
                return(NotFound());
            }

            return(View(obj));
        }