Exemplo n.º 1
0
 public override TEntityDto Insert(TEntityDto entityDto)
 {
     if (entityDto != null)
     {
         _dbContext.Add <TEntity>(Mapper.Map <TEntity>(entityDto));
         _dbContext.SaveChanges();
         return(entityDto);
     }
     return(null);
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("OrderNo,TotalAmount,UserName")] OrderViewModel order)
        {
            if (ModelState.IsValid)
            {
                Order o = new Order
                {
                    OrderNo     = order.OrderNo,
                    TotalAmount = order.TotalAmount,
                    UserName    = order.UserName,
                    CreateTime  = DateTime.Now
                };
                _context.Add(o);
                await _context.SaveChangesAsync();

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