public async Task <IActionResult> Create(SalesRecord salesRecord)
        {
            if (!ModelState.IsValid)
            {
                var departaments = await _salesRecordService.FindAllAsync();

                return(View());
            }
            await _salesRecordService.InsertAsync(salesRecord);

            return(RedirectToAction(nameof(Records)));
        }
예제 #2
0
        public async Task <IActionResult> Create(SalesRecord salesRecord)
        {
            if (!ModelState.IsValid)
            {
                var sellers = await _sellerService.FindAllAsync();

                var viewModel = new SalesRecordFormViewModel(salesRecord, sellers);
                return(View(viewModel));
            }

            await _salesRecordService.InsertAsync(salesRecord);

            return(RedirectToAction(nameof(Index)));
        }
예제 #3
0
        public async Task <IActionResult> Create(SalesRecord salesRecord)
        {
            if (!ModelState.IsValid)
            {
                var sellers = await _salesRecordeServices.FindAllAsync();

                var viewModel = new SalesRecordFormViewModel {
                    Sellers = sellers
                };
                return(View(viewModel));
            }

            //salesRecord.Status = Enum.Parse<SaleStatus>(ViewData["StatusId"].ToString());
            salesRecord.Status = Enum.Parse <SaleStatus>(ViewData["SaleStatusId"].ToString());
            salesRecord.Date   = DateTime.Now.Date;
            await _salesRecordeServices.InsertAsync(salesRecord);

            return(RedirectToAction(nameof(Index)));
        }