public void Add(SalesTransaction item)
 {
     if (item is Invoice invoice)
     {
         _invoiceRepository.Add(invoice);
     }
     else
     {
         throw new ArgumentException("Item must be Invoice");
     }
 }
Ejemplo n.º 2
0
        public IActionResult Create(StudentCreateModel student)
        {
            var s = new Student()
            {
                name = student.FirstName + student.LastName,
                age  = student.Age,
            };
            var newModel = _repostory.Add(s);

            // return View(nameof(ShowOne), newModel); //这种返回 虽然页面变了但是url没有变
            return(RedirectToAction(nameof(ShowOne), new{ id = newModel.id })); //重定向指的是url改变
        }