Beispiel #1
0
        public async Task <ActionResult> CreateOptionToRol(int?id)
        {
            if (id == null)
            {
                return(View("Error"));
            }

            var rol = await _db.Rols.FindAsync(id);

            if (rol == null)
            {
                return(View("Error"));
            }


            ViewBag.StatusId = new SelectList(_db.Status, "StatusId", "Name");
            ViewBag.OptionId = new SelectList(_db.Options.OrderBy(t => t.Name), "OptionId", "Description");

            ViewBag.RolId = new SelectList(_db.Rols.Where(t => t.AuthorId == _db.Authors.FirstOrDefault().AuthorId).OrderBy(t => t.Name), "RolId", "Name");
            var view = new OptionRol
            {
                RolId     = rol.RolId,
                FromDate  = DateTime.Today,
                ToDate    = DateTime.Today,
                Edit      = true,
                Delete    = true,
                Create    = true,
                Undefined = true,
                Index     = true,
                Details   = true
            };

            return(View(view));
        }
Beispiel #2
0
        public async Task <ActionResult> EditOptionToRol(OptionRol optionRol)
        {
            if (ModelState.IsValid)
            {
                _db.Entry(optionRol).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(RedirectToAction($"DetailsRol/{optionRol.RolId}"));
            }
            ViewBag.OptionId = new SelectList(_db.Options, "OptionId", "Name", optionRol.OptionId);
            ViewBag.RolId    = new SelectList(_db.Rols, "RolId", "Name", optionRol.RolId);
            ViewBag.StatusId = new SelectList(_db.Status, "StatusId", "Name", optionRol.StatusId);
            return(View(optionRol));
        }
Beispiel #3
0
        public async Task <ActionResult> CreateOptionToRol(OptionRol optionRol)
        {
            if (ModelState.IsValid)
            {
                _db.OptionRols.Add(optionRol);
                await _db.SaveChangesAsync();

                return(RedirectToAction($"DetailsRol/{optionRol.RolId}"));
            }


            //ViewBag.AuthorId = new SelectList(Db.Authors, "AuthorId", "Name", rol.AuthorId);
            //ViewBag.StatusId = new SelectList(Db.Status, "StatusId", "Name", rol.StatusId);

            ViewBag.StatusId = new SelectList(_db.Status, "StatusId", "Name", optionRol.StatusId);
            ViewBag.OptionId = new SelectList(_db.Options.OrderBy(t => t.Name), "OptionId", "Name", optionRol.OptionId);
            ViewBag.RolId    = new SelectList(_db.Rols.Where(t => t.AuthorId == _db.Authors.FirstOrDefault().AuthorId).OrderBy(t => t.Name), "RolId", "Name", optionRol.RolId);

            //ViewBag.OptionId = new SelectList(Db.Options, "OptionId", "Name", optionRol.OptionId);
            //ViewBag.RolId = new SelectList(Db.Rols, "RolId", "Name", optionRol.RolId);
            //ViewBag.StatusId = new SelectList(Db.Status, "StatusId", "Name", optionRol.StatusId);
            return(View(optionRol));
        }