Esempio n. 1
0
        public T Add(T itemToAdd)
        {
            var entity = dbContext.Add <T>(itemToAdd);

            dbContext.SaveChanges();
            return(entity.Entity);
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Name,PhoneId")] Phone phone)
        {
            if (ModelState.IsValid)
            {
                phone.PhoneId = Guid.NewGuid();
                _context.Add(phone);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(phone));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("UserName,Email,Password,AdminId")] Admin admin)
        {
            if (ModelState.IsValid)
            {
                admin.AdminId = Guid.NewGuid();
                _context.Add(admin);
                await _context.SaveChangesAsync();

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