public bool Create(ViewModels.RoleClassViewModel roleClassViewModel)
 {
     bool ret = false;
     try
     {
         RoleClass roledate = new RoleClass();
         
         roledate.RoleID = roleClassViewModel.RoleID;
         roledate.Name = roleClassViewModel.Name;
         
         db.RoleClass.Add(roledate);
         db.SaveChanges();
                         
         ret = true;
     }
     catch
     {
     }
     return ret;
 }
        public bool Update(ViewModels.RoleClassViewModel roleClassViewModel)
        {
            bool ret = false;
            try
            {
                if (roleClassViewModel.RoleID == roleClassViewModel.OldRoleID)
                {
                    RoleClass role = db.RoleClass.Find(roleClassViewModel.OldRoleID);

                    role.Name = roleClassViewModel.Name;

                    db.SaveChanges();                    
                    ret = true;
                }
                else
                {
                    RoleClass roledate = new RoleClass();

                    roledate.RoleID = roleClassViewModel.RoleID;
                    roledate.Name = roleClassViewModel.Name;

                    db.RoleClass.Add(roledate);
                    db.SaveChanges();

                    var qry = db.UserData.Where(x => x.RoleID == roleClassViewModel.OldRoleID);
                    foreach (UserData o in qry)
                    {
                        o.RoleID = roleClassViewModel.RoleID;

                    }

                    var qry2 = db.RoleToMeunClass.Where(x => x.RoleID == roleClassViewModel.OldRoleID);
                    foreach (RoleToMeunClass o in qry2)
                    {
                        o.RoleID = roleClassViewModel.RoleID;

                    }

                    db.SaveChanges();

                    RoleClass role = db.RoleClass.Find(roleClassViewModel.OldRoleID);
                    db.RoleClass.Remove(role);
                    db.SaveChanges();
                    ret = true;
                }
            }
            catch (DbUpdateConcurrencyException ex)
            {
                // Update the values of the entity that failed to save from the store
                ex.Entries.Single().Reload();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages = ex.EntityValidationErrors
                         .SelectMany(x => x.ValidationErrors)
                         .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                // Combine the original exception message with the new one.
                var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                // Throw a new DbEntityValidationException with the improved exception message.
                throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
            }
            return ret;
        }