コード例 #1
0
        public ActionResult AddStudent(FormCollection collection)
        {
            int studentIdToAdd = int.Parse(collection.GetValue("student").AttemptedValue);
            int projectId = int.Parse(collection.GetValue("projectID").AttemptedValue);
            int groupId = int.Parse(collection.GetValue("groupID").AttemptedValue);
            DAOStudent studentdao = DatabaseFactory.getInstance().getDAOStudent();
            DAOProject projectdao = DatabaseFactory.getInstance().getDAOProject();
            BarometerDataAccesLayer.User studentUser = studentdao.getStudentInfo(studentIdToAdd);
            IEnumerable<BarometerDataAccesLayer.ProjectMember> member = studentUser.ProjectMembers.Where(pm => pm.project_group_id == groupId);
            if (member.Count() == 0)
            {
                BarometerDataAccesLayer.ProjectMember pMember = new BarometerDataAccesLayer.ProjectMember();
                pMember.User = studentUser;
                pMember.project_group_id = groupId;
                BarometerDataAccesLayer.DatabaseClassesDataContext context = DatabaseFactory.getInstance().getDataContext();
                context.ProjectMembers.InsertOnSubmit(pMember);
                context.SubmitChanges();
            }

            return RedirectToAction("ProjectGroups", new { groupId = groupId });
        }
コード例 #2
0
        public ActionResult AddStudent(FormCollection collection)
        {
            int        studentIdToAdd = int.Parse(collection.GetValue("student").AttemptedValue);
            int        projectId      = int.Parse(collection.GetValue("projectID").AttemptedValue);
            int        groupId        = int.Parse(collection.GetValue("groupID").AttemptedValue);
            DAOStudent studentdao     = DatabaseFactory.getInstance().getDAOStudent();
            DAOProject projectdao     = DatabaseFactory.getInstance().getDAOProject();

            BarometerDataAccesLayer.User studentUser = studentdao.getStudentInfo(studentIdToAdd);
            IEnumerable <BarometerDataAccesLayer.ProjectMember> member = studentUser.ProjectMembers.Where(pm => pm.project_group_id == groupId);

            if (member.Count() == 0)
            {
                BarometerDataAccesLayer.ProjectMember pMember = new BarometerDataAccesLayer.ProjectMember();
                pMember.User             = studentUser;
                pMember.project_group_id = groupId;
                BarometerDataAccesLayer.DatabaseClassesDataContext context = DatabaseFactory.getInstance().getDataContext();
                context.ProjectMembers.InsertOnSubmit(pMember);
                context.SubmitChanges();
            }

            return(RedirectToAction("ProjectGroups", new { groupId = groupId }));
        }