コード例 #1
0
ファイル: StudentRepository.cs プロジェクト: punj-aab/School
 public void AssignSubjectToTeacher(StaffViewModel objVM)
 {
     foreach (var data in objVM.ListFields)
     {
         DBConnectionString.TeacherSubject teacherSubject = new DBConnectionString.TeacherSubject();
         teacherSubject.CourseId = data.CourseId;
         teacherSubject.ClassId = data.ClassId;
         teacherSubject.SectionId = data.SectionId;
         teacherSubject.SubjectId = data.SubjectId;
         teacherSubject.DepartmentId = data.DepartmentId;
         teacherSubject.UserId = objVM.UserId;
         teacherSubject.StaffId = objVM.StaffId;
         teacherSubject.Insert();
     }
 }
コード例 #2
0
ファイル: StudentRepository.cs プロジェクト: punj-aab/School
 public long CreateNewStaff(StaffViewModel objViewModel)
 {
     DBConnectionString.Staff objStaff = new DBConnectionString.Staff();
     objStaff.UserId = objViewModel.UserId;
     objStaff.Title = objViewModel.Title;
     objStaff.InsertedOn = DateTime.Now;
     objStaff.InsertedBy = objViewModel.InsertedBy;
     objStaff.Title = objViewModel.Title;
     objStaff.Email = objViewModel.Email;
     objStaff.StaffTypeId = objViewModel.StaffTypeId;
     objStaff.OrganizationId = objViewModel.OrganizationId;
     objStaff.FullName = objViewModel.Profile.FirstName + " " + objViewModel.Profile.LastName;
     objStaff.Insert();
     return objStaff.StaffId;
 }
コード例 #3
0
ファイル: StaffController.cs プロジェクト: punj-aab/School
        public ActionResult Create(StaffViewModel objViewModel)
        {
            string token = this.CreateToken(objViewModel, _userStatistics.UserId, _userStatistics.OrganizationId);

            if (!(string.IsNullOrEmpty(token)))
            {
                long userId = WebSecurity.RegisterNewUser(objViewModel.Email, "none", objViewModel.Email, false, objViewModel.Profile.FirstName, objViewModel.Profile.LastName, objViewModel.OrganizationId, token);
                DBConnectionString.Profile Profile = new DBConnectionString.Profile();
                if (userId != -1)
                {
                    Profile.UserId = userId;
                    Profile.Title = objViewModel.Profile.Title;
                    Profile.Address1 = "none";
                    Profile.Address2 = "none";
                    Profile.InsertedOn = DateTime.Now;
                    Profile.EmailAddress1 = objViewModel.Email;
                    Profile.HomeTelephoneNumber = objViewModel.Profile.HomeTelephoneNumber;
                    Profile.SecurityQuestionId = 1;
                    Profile.SecurityAnswer = "none";
                    Profile.DateOfBirth = objViewModel.DateOfBirth;
                    Profile.ModifiedOn = null;
                    Profile.MobileNumber = objViewModel.Profile.MobileNumber;

                    int recAffected = Convert.ToInt32(Profile.Insert());
                    long id = Profile.ProfileId;
                    string roleName = UserRoles.Student.ToString(); //((UserRoles)Convert.ToInt16(Token.RoleId)).ToString();
                    Roles.AddUserToRole(objViewModel.Email, roleName);
                    //objViewModel.UserId = userId;

                    objViewModel.InsertedBy = _userStatistics.UserId;
                    objViewModel.OrganizationId = _userStatistics.OrganizationId;
                    objViewModel.UserId = userId;
                    objViewModel.StaffId = this.repository.CreateNewStaff(objViewModel);

                    this.repository.AssignSubjectToTeacher(objViewModel);
                    this.repository.SetStaffPermissions(objViewModel);//Assign Staff Permissions
                    SaveFiles(token, this.GetType().Name, objViewModel.StaffId);
                    EmailHandler.Utilities.SendRegistationEmail(token, objViewModel.Email);
                    return RedirectToAction("Index");
                }
            }
            StaffViewModel objVM = this.LoadViewModel();
            return View(objVM);
        }
コード例 #4
0
ファイル: StudentRepository.cs プロジェクト: punj-aab/School
        public void UpdateStaff(StaffViewModel objVM)
        {
            DBConnectionString.Profile profile = DBConnectionString.Profile.Fetch("select * from profile where userId=@0", objVM.UserId).SingleOrDefault();
            DBConnectionString.Staff staff = DBConnectionString.Staff.Fetch("select * from staff where userId=@0", objVM.UserId).SingleOrDefault();
            DBConnectionString.User user = DBConnectionString.User.Fetch("select * from Users where userId=@0", objVM.UserId).SingleOrDefault();

            if (profile != null)
            {
                profile.Title = objVM.Title;
                profile.DateOfBirth = objVM.DateOfBirth;
                profile.MobileNumber = objVM.MobileNumber;
                profile.HomeTelephoneNumber = objVM.HomeTelephoneNumber;
                profile.EmailAddress1 = objVM.Email;
                profile.Update();
            }

            if (staff != null)
            {
                staff.StaffTypeId = objVM.StaffTypeId;
                staff.Email = objVM.Email;
                staff.Update();
            }

            if (user != null)
            {
                user.FirstName = objVM.FirstName;
                user.LastName = objVM.LastName;
                user.Email = objVM.Email;
                user.Update();
            }
            objVM.StaffPermission.UserId = objVM.UserId;
            this.UpdateStaffPermissions(objVM.StaffPermission);
        }
コード例 #5
0
ファイル: StudentRepository.cs プロジェクト: punj-aab/School
        public bool SetStaffPermissions(StaffViewModel objVM)
        {
            DBConnectionString.StaffPermission staffPermission = new DBConnectionString.StaffPermission();
            //Basic
            staffPermission.SendClassEmails = true;
            staffPermission.ViewClassEmails = true;
            staffPermission.SendClassEletters = true;
            staffPermission.ViewClassEletters = true;
            staffPermission.SendClassSms = true;
            staffPermission.ViewClassSms = true;
            staffPermission.CreateManageCalendarEvents = true;
            staffPermission.CreateManageCourseWork = true;
            staffPermission.ViewTimeTable = true;
            staffPermission.CreateManageAttendance = true;
            staffPermission.SelfPayments = true;
            staffPermission.CreateManageGroups = true;

            //Communication
            staffPermission.SendEmail = objVM.Communication.SendEmail;
            staffPermission.ViewEmail = objVM.Communication.ViewEmail;
            staffPermission.SendEletter = objVM.Communication.SendEletter;
            staffPermission.ViewEletter = objVM.Communication.ViewEletter;
            staffPermission.SendSms = objVM.Communication.SendSmsMessage;
            staffPermission.ViewSms = objVM.Communication.ViewSmsMessage;
            staffPermission.AbsentReporting = objVM.Communication.AbsentReporting;
            staffPermission.PrintLetters = objVM.Communication.PrintLetters;
            staffPermission.TopUpSMSBalance = objVM.Communication.TopUpSMSBalance;
            ///Payments
            staffPermission.CreateAndManageFee = objVM.Payment.CreateAndManageFee;
            staffPermission.CreateAndManageTrips = objVM.Payment.CreateAndManageTrips;
            staffPermission.CreateAndManageTickets = objVM.Payment.CreateAndManageTickets;
            staffPermission.CreateAndManageShop = objVM.Payment.CreateAndManageShop;
            staffPermission.ManageRefunds = objVM.Payment.ManageRefunds;
            staffPermission.ManageCashPayments = objVM.Payment.ManageCashPayments;
            staffPermission.ManageOrders = objVM.Payment.ManageOrders;
            //GroupAndIndividuals
            staffPermission.CreateAndManageStaff = objVM.GroupAndIndividuals.CreateAndManageStaff;
            staffPermission.AssignTeachers = objVM.GroupAndIndividuals.AssignTeachers;
            staffPermission.AssignDepartments = objVM.GroupAndIndividuals.AssignDepartments;
            staffPermission.CreateAndManageStudents = objVM.GroupAndIndividuals.CreateAndManageStudents;
            staffPermission.ManageParents = objVM.GroupAndIndividuals.ManageParents;
            staffPermission.CreateAndManageGroups = objVM.GroupAndIndividuals.CreateAndManageGroups;
            staffPermission.ViewStudents = objVM.GroupAndIndividuals.ViewStudents;
            staffPermission.ViewStaff = objVM.GroupAndIndividuals.ViewStaff;
            staffPermission.ViewParents = objVM.GroupAndIndividuals.ViewParents;
            //Academic
            staffPermission.CreateAndManageCalendarEvents = objVM.Academic.CreateAndManageCalendarEvents;
            staffPermission.ViewCalendarEvents = objVM.Academic.ViewCalendarEvents;
            staffPermission.CreateAndManageCoursework = objVM.Academic.CreateAndManageCoursework;
            staffPermission.CreateAndManageAttendance = objVM.Academic.CreateAndManageAttendance;
            staffPermission.CreateAndManageTimetable = objVM.Academic.CreateAndManageTimetable;
            staffPermission.ViewTimeTables = objVM.Academic.ViewTimeTable;
            //Reports:
            staffPermission.ImportData = objVM.Reports.ImportData;
            staffPermission.ExportData = objVM.Reports.ExportData;
            staffPermission.ManagePaymentReports = objVM.Reports.ManagePaymentReports;
            staffPermission.ManageAcademicReports = objVM.Reports.ManageAcademicReports;

            staffPermission.CreatedBy = objVM.InsertedBy;
            staffPermission.InsertedOn = DateTime.Now;
            staffPermission.UserId = objVM.UserId;
            if (Convert.ToInt32(staffPermission.Insert()) > 0)
            {
                return true;
            }
            return false;
        }
コード例 #6
0
ファイル: StaffController.cs プロジェクト: punj-aab/School
 public string CreateToken(StaffViewModel objViewModel, long userId, long organizationId)
 {
     int recordAffected = 0;
     DBConnectionString.RegistrationToken registrationToken = new DBConnectionString.RegistrationToken();
     registrationToken.OrganizationId = organizationId;
     // registrationToken.CourseId = (int)objViewModel.CourseId;
     // registrationToken.ClassId = objViewModel.ClassId;
     // registrationToken.SectionId = objViewModel.SectionId;
     //if (objViewModel.DepartmentId != null)
     //{
     //    registrationToken.DepartmentId = (int)objViewModel.DepartmentId;
     //}
     registrationToken.Token = UserStatistics.GenerateToken();
     registrationToken.CreatedBy = userId;
     registrationToken.RoleId = (int)UserRoles.Teacher;
     registrationToken.InsertedOn = DateTime.Now;
     recordAffected = Convert.ToInt32(registrationToken.Insert());
     if (recordAffected > 0)
     {
         return registrationToken.Token;
     }
     return string.Empty;
 }
コード例 #7
0
ファイル: StaffController.cs プロジェクト: punj-aab/School
 public void SetPermissions(StaffViewModel objVM)
 {
     //DBConnectionString.StaffPermission staffPermission = new DBConnectionString.StaffPermission();
     //staffPermission.PermissionCategoryId = PermissionCategory.Messaging;
     //staffPermission.PermissionId = Permission.SendEletter;
     //staffPermission.Status = objVM.Messaging.SendEletters;
     //staffPermission.CreatedBy = _userStatistics.UserId;
     //staffPermission.InsertedOn = DateTime.Now;
     //staffPermission.Insert();
 }
コード例 #8
0
ファイル: StaffController.cs プロジェクト: punj-aab/School
        public StaffViewModel LoadViewModel()
        {
            StaffViewModel objVM = new StaffViewModel();
            ListFields objFields = null;
            objVM.ListFields = new List<ListFields>();

            SelectList classList = null;
            SelectList courseList = null;
            SelectList sectionList = null;
            SelectList departmentList = null;
            SelectList subjectList = null;
            SelectList staffTypeList = null;
            this.LoadSelectLists(out  classList, out  courseList, out  sectionList, out  departmentList, out subjectList, out staffTypeList, false);

            for (int i = 0; i < 10; i++)
            {
                objFields = new ListFields();
                objFields.CourseList = courseList;
                objFields.DepartmentList = departmentList;
                objFields.ClassList = classList;
                objFields.SectionList = sectionList;
                objFields.SubjectList = subjectList;
                objVM.ListFields.Add(objFields);
            }
            objVM.StaffTypeList = staffTypeList;
            return objVM;
        }
コード例 #9
0
ファイル: StaffController.cs プロジェクト: punj-aab/School
 public ActionResult Edit(StaffViewModel objVM)
 {
     objVM.StaffPermission.UpdatedBy = _userStatistics.UserId;
     this.repository.UpdateStaff(objVM);
     return RedirectToAction("Index");
 }