예제 #1
0
        public async Task <IActionResult> Create([Bind("CustomerId,CompanyName,ContactName,ContactTitle,Address,City,Region,PostalCode,Country,Phone,Fax")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
예제 #2
0
        public async Task <int> Handle(CreateRoomCommand request, CancellationToken cancelationToken)
        {
            var entity = new Room
            {
                Calendar = request.Calendar,
                Number   = request.Calendar,
                Price    = request.Price
            };

            _context.Add(entity);
            await _context.SaveChangesAsync(cancelationToken);

            return(entity.RoomId);
        }
예제 #3
0
 public virtual TEntity Add(TEntity entity)
 {
     _dbContext.Add(entity);
     _dbContext.SaveChanges();
     return(entity);
 }
예제 #4
0
 private void AddCustomer(Customer customer)
 {
     _context.Add(customer);
     _context.SaveChanges();
 }