public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description")] Genr genr) { if (id != genr.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(genr); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GenrExists(genr.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(genr)); }
public static GenrDto FroGenr(this GenrDto dto, Genr a) { dto.Id = a.Id; dto.Title = a.Title; dto.Info = a.Info; //foreach (var p in a.GenrBooks) //{ // dto.GenrBooks.Add(p.ToGenrBookDto()); //} return(dto); }
public async Task <IActionResult> Create([Bind("Id, Name,Description")] Genr genr) { if (ModelState.IsValid) { _context.Add(genr); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(genr)); }
public static GenrDto ToGenrDto(this Genr a) { var b = new GenrDto { Id = a.Id, Title = a.Title, Info = a.Info }; //ICollection<GenrBook> genre = a.GenrBooks; //b.GenrBooks = new List<GenrBookDto>(); //foreach (var p in genre) //{ // b.GenrBooks.Add(p.ToGenrBookDto()); //} return(b); }
public static Genr ToGenr(this GenrDto dto) { var b = new Genr() { Id = dto.Id, Title = dto.Title, Info = dto.Info, }; //ICollection<GenrBookDto> genre = dto.GenrBooks; //b.GenrBooks = new List<GenrBook>(); //foreach (var p in genre) //{ // b.GenrBooks.Add(p.ToGenrBook()); //} return(b); }