Beispiel #1
0
        public void CreateRecord(Record record)
        {
            if (record == null)
            {
                throw new System.Exception(nameof(record));
            }

            _context.Add(record);
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("UserId,FirstName,Surname,RentedRecords")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
        public async Task <IActionResult> Create([Bind("Id,RecordName,Artist,ReleaseDate,IsRented,RentDate")] Record @record)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@record);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(@record));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("ArtistId,ArtistName")] Artist artist)
        {
            if (ModelState.IsValid)
            {
                _context.Add(artist);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(artist));
        }
Beispiel #5
0
        public async Task <IActionResult> Create([Bind("CdId,CdName,ArtistId,ArtistName")] Record @record)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@record);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ArtistId"] = new SelectList(_context.Artist, "ArtistId", "ArtistId", @record.ArtistId);
            return(View(@record));
        }
 public Record Create(Record item)
 {
     _context.Add(item);
     _context.SaveChanges();
     return(item);
 }