Ejemplo n.º 1
0
 public List <UserDetails> GetAllUser()
 {
     using (var context = new AdminAppEntities())
     {
         var userList = context.UserDetails.ToList();
         if (userList != null)
         {
             return(userList.Select(x => new UserDetails
             {
                 CompanyID = x.CompanyID,
                 FirstName = x.FirstName,
                 LastName = x.LastName,
                 PrimaryEmailID = x.PrimaryEmailID,
                 PhoneNumber = x.PhoneNumber,
                 EmployeeCode = x.EmployeeCode,
                 Address = x.Address,
                 Address1 = x.Address1,
                 City = x.City,
                 State = x.State,
                 Country = x.Country,
                 Pincode = x.Pincode,
                 RoleId = x.RoleId,
                 UserId = x.UserID
             }).ToList());
         }
         return(null);
     }
 }
Ejemplo n.º 2
0
        public bool UpdateUser(UserDetails userDetails)
        {
            bool result = true;

            using (var context = new AdminAppEntities())
            {
                UserDetail details       = context.UserDetails.Where(x => x.UserID == userDetails.UserId).FirstOrDefault();
                UserDetail updatedetails = new UserDetail
                {
                    CompanyID      = userDetails.CompanyID,
                    RoleId         = userDetails.RoleId,
                    FirstName      = userDetails.FirstName,
                    LastName       = userDetails.LastName,
                    PrimaryEmailID = userDetails.PrimaryEmailID,
                    PhoneNumber    = userDetails.PhoneNumber,
                    EmployeeCode   = userDetails.EmployeeCode,
                    Address        = userDetails.Address,
                    Address1       = userDetails.Address1,
                    City           = userDetails.City,
                    State          = userDetails.State,
                    Country        = userDetails.Country,
                    Pincode        = userDetails.Pincode,
                    Active         = true,
                    UserID         = userDetails.UserId
                };
                context.Entry(details).CurrentValues.SetValues(updatedetails);
                context.SaveChanges();

                UserAuthentication userAuth = context.UserAuthentications.Where(x => x.UserID == userDetails.UserId).FirstOrDefault();
                context.UserAuthentications.Remove(userAuth);
                context.SaveChanges();

                UserAuthentication userAuthNew = new UserAuthentication
                {
                    UserID   = userDetails.UserId,
                    UserName = userDetails.UserName,
                    Password = userDetails.Password
                };
                context.UserAuthentications.Add(userAuthNew);
                context.SaveChanges();

                return(result);
            }
        }
Ejemplo n.º 3
0
        public bool UpdateRole(RoleDetails roleDetails)
        {
            bool res = false;

            using (var context = new AdminAppEntities())
            {
                Role roleDet = new Role
                {
                    Name   = roleDetails.Name,
                    Active = true,
                    RoleId = roleDetails.RoleId
                };
                Role updateRole = context.Roles.Where(x => x.RoleId == roleDetails.RoleId).FirstOrDefault();
                context.Entry(updateRole).CurrentValues.SetValues(roleDet);
                context.SaveChanges();
                res = true;
            }
            return(res);
        }
Ejemplo n.º 4
0
        public bool SaveRole(RoleDetails roleDetails)
        {
            bool res = false;

            using (var context = new AdminAppEntities())
            {
                Role roleDet = new Role
                {
                    Name   = roleDetails.Name,
                    Active = true,
                    RoleId = roleDetails.RoleId
                };

                context.Roles.Add(roleDet);
                context.SaveChanges();
                res = true;
            }
            return(res);
        }
Ejemplo n.º 5
0
 public List <MenuPermission> GetPrivilegeByRole(int roleID)
 {
     using (var context = new AdminAppEntities())
     {
         var privItems = context.MenuPrivileges.Where(x => x.RoleID == roleID).ToList();
         if (privItems != null && privItems.Count > 0)
         {
             return(privItems.Select(x => new MenuPermission {
                 MenuID = x.MenuID,
                 RoleID = x.RoleID,
                 CanCreate = (bool)x.CanCreate,
                 CanEdit = (bool)x.CanEdit,
                 CanDelete = (bool)x.CanDelete,
                 CanView = (bool)x.CanView
             }).ToList());
         }
         return(null);
     }
 }
Ejemplo n.º 6
0
 public int SaveUser(UserDetails userDetails)
 {
     using (var context = new AdminAppEntities())
     {
         UserDetail details = new UserDetail {
             CompanyID      = userDetails.CompanyID,
             RoleId         = userDetails.RoleId,
             FirstName      = userDetails.FirstName,
             LastName       = userDetails.LastName,
             PrimaryEmailID = userDetails.PrimaryEmailID,
             PhoneNumber    = userDetails.PhoneNumber,
             EmployeeCode   = userDetails.EmployeeCode,
             Address        = userDetails.Address,
             Address1       = userDetails.Address1,
             City           = userDetails.City,
             State          = userDetails.State,
             Country        = userDetails.Country,
             Pincode        = userDetails.Pincode,
             Active         = true
         };
         context.UserDetails.Add(details);
         context.SaveChanges();
         if (details.UserID > 0)
         {
             UserAuthentication userAuth = new UserAuthentication
             {
                 UserID   = details.UserID,
                 UserName = userDetails.UserName,
                 Password = userDetails.Password
             };
             context.UserAuthentications.Add(userAuth);
             context.SaveChanges();
         }
         return(details.UserID);
     }
 }
Ejemplo n.º 7
0
        public bool SavePrivilege(MenuPermission priv)
        {
            bool result = false;

            using (var context = new AdminAppEntities())
            {
                var           privilege = context.MenuPrivileges.ToList();
                MenuPrivilege menuPriv  = new MenuPrivilege();
                menuPriv = privilege.Where(x => x.RoleID == priv.RoleID && x.MenuID == priv.MenuID).FirstOrDefault();
                if (menuPriv != null)
                {
                    context.MenuPrivileges.Remove(menuPriv);
                    context.SaveChanges();
                }
                MenuPrivilege menu = new MenuPrivilege
                {
                    MenuID    = priv.MenuID,
                    RoleID    = priv.RoleID,
                    CanCreate = priv.CanCreate,
                    CanEdit   = priv.CanEdit,
                    CanView   = priv.CanView,
                    CanDelete = priv.CanDelete
                };
                context.MenuPrivileges.Add(menu);
                context.SaveChanges();
                if (menu.PrivilegeID > 0)
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
Ejemplo n.º 8
0
 public List <Menu> GetMenu()
 {
     using (var context = new AdminAppEntities())
     {
         var menuList = context.MenuMasters.ToList();
         if (menuList != null)
         {
             return(menuList.Select(x => new Menu
             {
                 MenuName = x.MenuName,
                 MID = x.MenuId,
                 ActionName = x.ActionName,
                 ControllerName = x.ControllerName,
                 MenuParentID = (int)x.MenuParentId,
                 IconStyle = x.IconStyle,
                 MenuURL = x.MenuUrl
             }).ToList());
         }
         else
         {
             return(null);
         }
     }
 }