Exemplo n.º 1
0
        public static Models.ValidationResult AddGroup(Models.Group group, int userId)
        {
            using (var uow = new DAL.UnitOfWork())
            {
                var validationResult = ValidateGroup(group, true);
                if (validationResult.IsValid)
                {
                    uow.GroupRepository.Insert(group);
                    validationResult.IsValid = uow.Save();

                    //If Group management is being used add this group to the allowed users list
                    var userManagedGroups = BLL.UserGroupManagement.Get(userId);
                    if (userManagedGroups.Count > 0)
                    {
                        BLL.UserGroupManagement.AddUserGroupManagements(
                            new List <Models.UserGroupManagement>
                        {
                            new Models.UserGroupManagement
                            {
                                GroupId = group.Id,
                                UserId  = userId
                            }
                        });
                    }
                }

                return(validationResult);
            }
        }
Exemplo n.º 2
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     Group = !string.IsNullOrEmpty(Request["groupid"]) ? BLL.Group.GetGroup(Convert.ToInt32(Request.QueryString["groupid"])) : null;
     if (Group == null)
         RequiresAuthorization(Authorizations.SearchGroup);
     else
         RequiresAuthorizationOrManagedGroup(Authorizations.ReadGroup, Group.Id);
 }
        /// <summary>
        /// Method that evaluates a given group level based on the 
        /// level of the Students in it. The current logic is very simple:
        /// We get the Mode Level of all Students.
        /// </summary>
        /// <param name="group">A Group type object to evaluate level</param>
        /// <returns>The calculated level for the Group</returns>
        public int EvaluateGroupLevel(Group group)
        {
            var studentLevel = group.Students.GroupBy(v => v.Level)
            .OrderByDescending(g => g.Count())
            .First()
            .Key;

            return studentLevel;
        }
Exemplo n.º 4
0
        public static bool UpdateSmartMembership(Models.Group group)
        {
            BLL.GroupMembership.DeleteAllMembershipsForGroup(group.Id);
            var computers   = BLL.Computer.SearchComputersByName(group.SmartCriteria, Int32.MaxValue);
            var memberships = computers.Select(computer => new Models.GroupMembership {
                GroupId = @group.Id, ComputerId = computer.Id
            }).ToList();

            return(BLL.GroupMembership.AddMembership(memberships));
        }
Exemplo n.º 5
0
 public Student(string firstName, string lastName, int years, string fn, string telephone, string email,
     List<int> marks, int groupNumber, Group group)
     : this(firstName, lastName, years)
 {
     this.FN = fn;
     this.Telephone = telephone;
     this.Email = email;
     this.Marks = marks;
     this.GroupNumber = groupNumber;
     this.Group = group;
 }
        public void Update(int id, Group entry)
        {
            var group = groups.GetById(id);
            group.Level = entry.Level;
            group.Name = entry.Name;
            group.Notes = entry.Notes;
            group.Points = entry.Points;
            group.Experience = entry.Experience;
            group.AvatarUrl = entry.AvatarUrl;
            group.Affinity = entry.Affinity;

            groups.SaveChanges();
        }
Exemplo n.º 7
0
        public static int StartGroupUnicast(Models.Group group, int userId)
        {
            var count = 0;

            foreach (var computer in GetGroupMembers(group.Id))
            {
                if (new BLL.Workflows.Unicast(computer, "push", userId).Start() == "true")
                {
                    count++;
                }
            }
            return(count);
        }
Exemplo n.º 8
0
        public static Models.ValidationResult UpdateGroup(Models.Group group)
        {
            using (var uow = new DAL.UnitOfWork())
            {
                var validationResult = ValidateGroup(group, false);
                if (validationResult.IsValid)
                {
                    uow.GroupRepository.Update(group, group.Id);
                    validationResult.IsValid = uow.Save();
                }

                return(validationResult);
            }
        }
Exemplo n.º 9
0
        public static Models.ValidationResult ValidateGroup(Models.Group group, bool isNewGroup)
        {
            var validationResult = new Models.ValidationResult();

            if (string.IsNullOrEmpty(group.Name) || !group.Name.All(c => char.IsLetterOrDigit(c) || c == '_'))
            {
                validationResult.IsValid = false;
                validationResult.Message = "Group Name Is Not Valid";
                return(validationResult);
            }

            if (isNewGroup)
            {
                using (var uow = new DAL.UnitOfWork())
                {
                    if (uow.GroupRepository.Exists(h => h.Name == group.Name))
                    {
                        validationResult.IsValid = false;
                        validationResult.Message = "This Group Already Exists";
                        return(validationResult);
                    }
                }
            }
            else
            {
                using (var uow = new DAL.UnitOfWork())
                {
                    var originalGroup = uow.GroupRepository.GetById(group.Id);
                    if (originalGroup.Name != group.Name)
                    {
                        if (uow.GroupRepository.Exists(h => h.Name == group.Name))
                        {
                            validationResult.IsValid = false;
                            validationResult.Message = "This Group Already Exists";
                            return(validationResult);
                        }
                    }
                }
            }

            return(validationResult);
        }
        public Group Create(string name, string affinity, string notes, string avatarUrl)
        {
            var group = new Group()
            {
                Name = name,
                Affinity = affinity,
                Notes = notes,
                AvatarUrl = avatarUrl,
                Points = 0,
                Level = 0,
                Experience = 0,
                isDeleted = false
            };

            this.groups.Add(group);

            this.groups.SaveChanges();

            return group;
        }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            groupBasePage = (Page as Groups);
            Group = groupBasePage.Group;
            if (Group == null)
            {
                Level2_Edit.Visible = false;
                actions_left.Visible = false;
                return;
            }

            Level1.Visible = false;
            if (Group.Type == "standard")
            {
                addmembers.Visible = true;
                removemembers.Visible = true;
            }
            else
            {
                smart.Visible = true;
                currentmembers.Visible = true;
            }

        }
        /// <summary>
        /// Method that evaluates a given group experince based on the 
        /// experinces of the Students in it. The current logic is very simple:
        /// We get the Avarage Exp of all Students.
        /// </summary>
        /// <param name="group">A Group type object to evaluate experince</param>
        /// <returns>The calculated experience for the Group</returns>
        public int EvaluateGroupExperience(Group group)
        {
            var studentExperience = group.Students.Sum(x => x.Experience);

            return (int)(studentExperience / group.Students.Count());
        }
        /// <summary>
        /// Method that evaluates a given group points based on the 
        /// experinces of the Students in it. The current logic is very simple:
        /// We get the Avarage Points of all Students.
        /// </summary>
        /// <param name="group">A Group type object to evaluate points</param>
        /// <returns>The calculated points for the Group</returns>
        public int EvaluateGroupPoints(Group group)
        {
            var studentPoints = group.Students.Sum(x => x.Points);

            return (int)(studentPoints / group.Students.Count());
        }