Beispiel #1
0
        public void CompanieUserRoleSave(List <int> roleItems, int companyId)
        {
            FoxSecDBContext dBContext     = new FoxSecDBContext();
            int             currentUserId = 0;

            if (CurrentUser.Get().IsSuperAdmin)
            {
                currentUserId = companyId;
            }
            else if (CurrentUser.Get().IsCompanyManager)
            {
                currentUserId = CurrentUser.Get().CompanyId.Value;
            }

            var companieRolesRecords = dBContext.CompanieRoles.Where(y => y.CompanyId == currentUserId).Any() ? dBContext.CompanieRoles.Where(x => !x.IsDeleted && x.CompanyId == currentUserId).ToList() : null;

            if (companieRolesRecords != null)
            {
                foreach (var roles in companieRolesRecords)
                {
                    roles.IsDeleted = true;
                }
                dBContext.SaveChanges();
            }
            foreach (int roleId in roleItems)
            {
                var companieRoleModel = new CompanyRoleModel {
                    CompanyId = currentUserId, RoleId = roleId, IsDeleted = false
                };
                dBContext.CompanieRoles.Add(companieRoleModel);
                dBContext.SaveChanges();
            }
        }
Beispiel #2
0
        public string Approve_Unapprove(List <int> terminals, int status)
        {
            var    usr = CurrentUser.Get();
            string msg = "";

            if (status != 2)
            {
                foreach (var t in terminals)
                {
                    var data   = db.Database.SqlQuery <Terminal>("Select * from Terminal where Id=" + t).FirstOrDefault();
                    var update = db.Database.ExecuteSqlCommand("Update Terminal set ApprovedDevice=" + status + " where Id=" + t);
                    if (update > 0)
                    {
                        _logService.CreateLog(usr.Id, "Terminal", "", "", usr.CompanyId, "TerminalId " + data.TerminalId + (status == 0 ? "unapproved" : "approved") + " ");
                    }
                }
                db.SaveChanges();
                msg = status == 0 ? "selected terminals unapproved successfully" : "selected terminals approved successfully";
            }
            else
            {
                msg = "Please check status!!";
            }
            return(msg);
        }
Beispiel #3
0
        public ActionResult NotMovedAfterToDate(List <int> usersToDeactivate)
        {
            //var companiesRoles = db.UserLastMoves.Include("User").ToList();
            //db.User.Where(x => x.Id == 38).SingleOrDefault().IsDeleted=false;
            //userUpdate.IsDeleted = false;
            //db.SaveChanges();
            //db.Entry(userUpdate).State= System.Data.Entity.EntityState.Modified;

            //var filterCompaniesRoles = companiesRoles.Where(x => x.LastMoveTime <= DateTime.Now.AddDays(-60)).Distinct().ToList();
            if (usersToDeactivate != null)
            {
                foreach (int user in usersToDeactivate)
                {
                    db.User.Where(x => x.Id == (user)).SingleOrDefault().Active = false;
                    db.SaveChanges();
                }
            }


            return(null);
        }