コード例 #1
0
        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));
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }