// GET: Profile/Roles/Create
        public ActionResult Create()
        {
            MVRolesSetting RS = new MVRolesSetting();

            RS = RS.CreateNew(RS);
            return(View(RS));
        }
        // GET: Profile/Roles/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                HandleErrorInfo handeError = new HandleErrorInfo(new Exception(E.Message), "Roles", "Edit");
                return(View("Error", handeError));
            }
            MVRolesSetting RS = new MVRolesSetting();

            RS = RS.Update(id);

            return(View(RS));
        }
        public ActionResult Edit(MVRolesSetting MVRole)
        {
            var roles = db.AspNetRoles.FirstOrDefault(s => s.Id == MVRole.Role.Id);

            roles.IsActive        = MVRole.Role.IsActive;
            roles.Name            = MVRole.Role.Name;
            db.Entry(roles).State = EntityState.Modified;
            var deletePrev = db.Roleprimissions.Where(s => s.RoleId == roles.Id).ToList();

            db.Roleprimissions.RemoveRange(deletePrev);
            db.Roleprimissions.AddRange(MVRole.Pages);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(MVRolesSetting MVRole)
        {
            if (ModelState.IsValid)
            {
                MVRole.Role.IsActive = true;

                db.AspNetRoles.Add(MVRole.Role);

                db.Roleprimissions.AddRange(MVRole.Pages);
                try
                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        string err = string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                   eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            string errr = string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                        ve.PropertyName, ve.ErrorMessage);

                            throw new Exception(errr);
                        }
                    }
                }
                catch (System.Data.Entity.Infrastructure.DbUpdateException e)
                {
                    string err = e.Message;
                }

                return(RedirectToAction("Index"));
            }

            return(View(MVRole));
        }