public async Task <ActionResult> Edit(Guid id, [Bind("Id,Name,PersonId")] PersonTypes personTypes)
        {
            if (id != personTypes.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    using (var ctx = new MvcMovieCoreContext())
                    {
                        ctx.Update(personTypes);
                        await ctx.SaveChangesAsync();
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonTypeExists(personTypes.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["PersonId"] = new SelectList(new MvcMovieCoreContext().Person, "Id", "Name");
            return(View(personTypes));
        }
 // GET: PersonTypesController/Create
 public ActionResult Create()
 {
     using (var ctx = new MvcMovieCoreContext())
     {
         ViewData["PersonId"] = new SelectList(ctx.Person, "Id", "Name");
         return(View());
     }
 }
 // GET: PersonTypesController
 public async Task <ActionResult> Index()
 {
     using (var db = new MvcMovieCoreContext())
     {
         IQueryable <PersonTypes> personTypes = db.PersonType.Include(i => i.Person);
         return(View(await personTypes.ToListAsync()));
     }
 }
        public async Task <ActionResult> DeleteConfirmed(Guid id)
        {
            using (var ctx = new MvcMovieCoreContext())
            {
                var personType = await ctx.PersonType.FindAsync(id);

                ctx.PersonType.Remove(personType);
                await ctx.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
        }
        public async Task <ActionResult> Create([Bind("Id,Name,PersonId")] PersonTypes personTypes)
        {
            using (var ctx = new MvcMovieCoreContext())
            {
                if (ModelState.IsValid)
                {
                    personTypes.Id = Guid.NewGuid();
                    ctx.Add(personTypes);
                    await ctx.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                ViewData["PersonId"] = new SelectList(ctx.Person, "Id", "Name");
                return(View());
            }
        }
 // GET: PersonTypesController/Details/5
 public async Task <ActionResult> Details(Guid?id)
 {
     using (var db = new MvcMovieCoreContext())
     {
         IQueryable <PersonTypes> personTypes;
         if (id.HasValue)
         {
             personTypes = db.PersonType.Include(i => i.Person).Where(f => f.Id == id);
         }
         else
         {
             personTypes = db.PersonType.Include(i => i.Person);
         }
         return(View(await personTypes.ToListAsync()));
     }
 }
        // GET: PersonTypesController/Edit/5
        public async Task <ActionResult> Edit(Guid?id)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }

            using (var ctx = new MvcMovieCoreContext())
            {
                var personTypes = await ctx.PersonType.Include(i => i.Person).FirstOrDefaultAsync(f => f.Id == id);

                if (personTypes == null)
                {
                    return(NotFound());
                }

                ViewData["PersonId"] = new SelectList(ctx.Person, "Id", "Name");
                return(View(personTypes));
            }
        }
Exemple #8
0
 public MoviesController(MvcMovieCoreContext context)
 {
     _context = context;
 }
Exemple #9
0
 public PersonController(MvcMovieCoreContext context)
 {
     _context = context;
 }
 public GetRandomAdultMovieController(MvcMovieCoreContext context)
 {
     _context = context;
 }
 private bool PersonTypeExists(Guid id)
 {
     using (var ctx = new MvcMovieCoreContext())
         return(ctx.PersonType.Any(a => a.Id == id));
 }