public ActionResult Role_edit(long id, ETRole updateRole)
        {
            TempData["messagealert"] = string.Empty;

            if (ModelState.IsValid)
            {
                Role = new ETRole();
                Role = repRole.GetRole(id);

                if (repRole.RoleIsExist(updateRole.RoleName, id))
                {
                    ViewBag.messagealert = "Role already exist";
                    return(View(Role));
                }
                else
                {
                    Role.RoleName                = updateRole.RoleName;
                    Role.IsActive                = updateRole.IsActive;
                    Role.ModifiedBy              = Convert.ToInt64(Session["UserID"]);
                    Role.ModifiedDate            = DateTime.Now;
                    dbEntities.Entry(Role).State = EntityState.Modified;
                    dbEntities.SaveChanges();
                    if (Role.RoleID != 0)
                    {
                        TempData["messagealert"] = Status.Update;
                    }
                }
                return(RedirectToAction("Index", "Role"));
            }
            return(View());
        }
 public ActionResult Role_edit(long Id)
 {
     ViewBag.messagealert = string.Empty;
     Role = new ETRole();
     Role = repRole.GetRole(Id);
     return(View(Role));
 }
        public ActionResult Role_add(ETRole Role)
        {
            TempData["messagealert"] = string.Empty;
            ViewBag.messagealert     = string.Empty;

            if (ModelState.IsValid)
            {
                if (Role != null)
                {
                    if (repRole.RoleIsExist(Role.RoleName, 0))
                    {
                        ViewBag.messagealert = "Role already exist";
                        return(View(Role));
                    }
                    else
                    {
                        Role.CreatedBy    = Convert.ToInt64(Session["UserID"]);
                        Role.CreatedDate  = DateTime.Now;
                        Role.ModifiedBy   = Convert.ToInt64(Session["UserID"]);
                        Role.ModifiedDate = DateTime.Now;
                        dbEntities.ETRoles.Add(Role);
                        dbEntities.SaveChanges();
                        if (Role.RoleID != 0)
                        {
                            TempData["messagealert"] = Status.Save;
                        }
                    }
                }
                return(RedirectToAction("Index", "Role"));
            }
            return(View());
        }
        public bool RoleUpdateStatus(bool status, long Roleid)
        {
            Role = new ETRole();
            Role = repRole.GetRole(Roleid);

            if (Role != null)
            {
                if (status)
                {
                    Role.IsActive     = false;
                    Role.ModifiedBy   = Convert.ToInt64(Session["UserID"]);
                    Role.ModifiedDate = DateTime.Now;
                }
                else
                {
                    Role.ModifiedBy   = Convert.ToInt64(Session["UserID"]);
                    Role.ModifiedDate = DateTime.Now;
                    Role.IsActive     = true;
                }
                dbEntities.Entry(Role).State = EntityState.Modified;
                dbEntities.SaveChanges();
                return(true);
            }

            return(false);
        }
        public bool RoleDelete(long Roleid)
        {
            if (!dbEntities.ETUsers.Where(x => x.UserID == 1).Any()) // Need to change
            {
                TempData["messagealert"] = Status.Delete;
                Role = new ETRole();
                Role = dbEntities.ETRoles.Where(x => x.RoleID == Roleid).SingleOrDefault();
                if (Role != null)
                {
                    dbEntities.ETRoles.Remove(Role);
                    dbEntities.SaveChanges();
                    return(true);
                }
            }
            return(false);

            //if (!dbEntities.TBL_ADMIN_USER.Where(x => x.ROLE_ID == id).Any())
            //{
            //    TempData["messagealert"] = Status.Delete;
            //    role = new TBL_ROLE();
            //    role = dbEntities.TBL_ROLE.Where(x => x.ROLE_ID == id && x.ROLE_NAME != "superadmin").SingleOrDefault();
            //    if (role != null)
            //    {
            //        dbEntities.TBL_ROLE.Remove(role);
            //        dbEntities.SaveChanges();
            //        return true;
            //    }
            //}
            //return false;
        }
 public ActionResult Role_view(long Id)
 {
     Role = repRole.GetRole(Id);
     return(View(Role));
 }