Exemplo n.º 1
0
 public bool Create(Organization objOrganization)
 {
     int recAffected = 0;
     DBConnectionString.Organization organization = new DBConnectionString.Organization();
     organization.Address1 = objOrganization.Address1;
     organization.Address2 = objOrganization.Address2;
     organization.City = objOrganization.City;
     organization.CountryId = objOrganization.CountryId;
     organization.CreatedBy = objOrganization.CreatedBy;
     organization.CreatedDate = DateTime.Now;
     organization.Email = objOrganization.Email;
     organization.OrganizationDesc = objOrganization.OrganizationDesc;
     organization.OrganizationName = objOrganization.OrganizationName;
     organization.OrganizationTypeId = objOrganization.OrganizationTypeId;
     organization.Phone1 = objOrganization.Phone1;
     organization.Phone2 = objOrganization.Phone2;
     organization.RegisterationNumber = objOrganization.RegisterationNumber;
     organization.StateId = objOrganization.StateId;
     recAffected = Convert.ToInt32(organization.Insert());
     if (recAffected > 0)
     {
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 public string AddOrganizations(string token, Organization objOrganization)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (StudentContext db = new StudentContext())
             {
                 objOrganization.CreatedDate = DateTime.Now;
                 objOrganization.CreatedBy = _userStatistics.UserId;
                 RegistrationToken objToken = new RegistrationToken();
                 objToken.Token = UserStatistics.GenerateToken();
                 objToken.RoleId = (int)UserRoles.OrganizationAdmin;
                 objToken.CreatedBy = _userStatistics.UserId;
                 if (objRep.CreateOrganization(objOrganization, objToken))
                 {
                     //objRep.CreateRegistrationToken(objToken);
                     SaveFiles(token, this.GetType().Name, objOrganization.OrganizationId);
                     EmailHandler.Utilities.SendRegistationEmail(objToken.Token, objOrganization.Email);
                     return Convert.ToString(true);
                 }
                 return Convert.ToString(false);
             }
         }
         return Convert.ToString(false);
     }
     catch (Exception ex)
     {
         return ex.Message.ToString();
     }
 }
Exemplo n.º 3
0
 public ActionResult AddOrganizations()
 {
     SelectList ContList = null;
     SelectList stateList = null;
     SelectList organizationTypeList = null;
     LoadSelectLists(out ContList, out stateList, out organizationTypeList);
     Organization objModel = new Organization();
     objModel.CountryList = ContList;
     objModel.StateList = stateList;
     objModel.OrganizationTypeList = organizationTypeList;
     return PartialView(objModel);
 }
Exemplo n.º 4
0
        public bool CreateOrganization(Organization objOrganization, RegistrationToken objToken)
        {
            var parameters = new
            {
                Address1 = objOrganization.Address1,
                Address2 = objOrganization.Address2,
                City = objOrganization.City,
                CountryId = objOrganization.CountryId,
                CreatedBy = objOrganization.CreatedBy,
                CreatedDate = DateTime.Now,
                Email = objOrganization.Email,
                OrganizationDesc = objOrganization.OrganizationDesc,
                OrganizationName = objOrganization.OrganizationName,
                OrganizationTypeId = objOrganization.OrganizationTypeId,
                Phone1 = objOrganization.Phone1,
                Phone2 = objOrganization.Phone2,
                RegisterationNumber = objOrganization.RegisterationNumber,
                StateId = objOrganization.StateId
            };
            using (IDbConnection connection = OpenConnection())
            {
                const string storedProcedure = "usp_addOrganization";
                int rowsAffected = 0;
                rowsAffected = connection.Execute(storedProcedure, parameters, commandType: CommandType.StoredProcedure);
                SetIdentity<int>(connection, id => objOrganization.OrganizationId = id);
                objToken.OrganizationId = objOrganization.OrganizationId;
                objToken.Email = objOrganization.Email;
                if (rowsAffected > 0)
                {
                    rowsAffected = 0;
                    rowsAffected = CreateRegistrationToken(objToken, connection);
                }

                if (rowsAffected > 0)
                {
                    return true;
                }
                return false;
            }
        }
Exemplo n.º 5
0
        public Schedule LoadScheduleLists(string userRole, long organizationId = -1, long scheduleId = -1)
        {
            Schedule schedule = null;
            if (scheduleId != -1)
            {
                schedule = this.GetSchedule(scheduleId);
            }
            if (schedule == null)
            {
                schedule = new Schedule();
            }
            //list class objects
            List<Organization> listOrganizations = new List<Organization>();
            List<Course> courseList = new List<Course>();
            List<Class> classList = new List<Class>();
            List<Subject> subjectList = new List<Subject>();
            List<Department> departmentList = new List<Department>();
            List<ClassRoom> classRoomList = new List<ClassRoom>();

            //class objects
            Organization objOrganization = null;
            Course objCourse = null;
            Class objClass = null;
            Subject objSubject = null;
            Department objDep = null;
            ClassRoom objRoom = null;

            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["StudentContext"].ConnectionString);
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            using (SqlCommand cmd = new SqlCommand("usp_getSchedules", con))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@userRole", SqlDbType.VarChar, 50).Value = userRole;
                cmd.Parameters.Add("@organizationId", SqlDbType.BigInt).Value = schedule.OrganizationId;
                cmd.Parameters.Add("@courseId", SqlDbType.BigInt).Value = schedule.CourseId;
                cmd.Parameters.Add("@departmentId", SqlDbType.BigInt).Value = schedule.DepartmentId;
                cmd.Parameters.Add("@classId", SqlDbType.BigInt).Value = schedule.ClassId;
                cmd.Parameters.Add("@createdByOrganization", SqlDbType.BigInt, 50).Value = organizationId;

                SqlDataAdapter adp = new SqlDataAdapter();
                adp.SelectCommand = cmd;
                DataSet dataSet = new DataSet();
                adp.Fill(dataSet);

                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    objOrganization = new Organization();
                    objOrganization.OrganizationId = Convert.ToInt64(row["OrganizationId"]);
                    objOrganization.OrganizationName = Convert.ToString(row["OrganizationName"]);
                    listOrganizations.Add(objOrganization);
                    if (userRole != "SiteAdmin")
                    {
                        schedule.OrganizationName = objOrganization.OrganizationName;
                    }
                }

                foreach (DataRow row in dataSet.Tables[1].Rows)
                {
                    objCourse = new Course();
                    objCourse.CourseId = Convert.ToInt64(row["CourseId"]);
                    objCourse.CourseName = Convert.ToString(row["CourseName"]);
                    courseList.Add(objCourse);
                }

                foreach (DataRow row in dataSet.Tables[2].Rows)
                {
                    objClass = new Class();
                    objClass.ClassId = Convert.ToInt64(row["ClassId"]);
                    objClass.ClassName = Convert.ToString(row["ClassName"]);
                    classList.Add(objClass);
                }

                foreach (DataRow row in dataSet.Tables[3].Rows)
                {
                    objSubject = new Subject();
                    objSubject.SubjectId = Convert.ToInt64(row["SubjectId"]);
                    objSubject.SubjectName = Convert.ToString(row["SubjectName"]);
                    subjectList.Add(objSubject);
                }

                foreach (DataRow row in dataSet.Tables[4].Rows)
                {
                    objDep = new Department();
                    objDep.DepartmentId = Convert.ToInt64(row["DepartmentId"]);
                    objDep.DepartmentName = Convert.ToString(row["DepartmentName"]);
                    departmentList.Add(objDep);
                }

                foreach (DataRow row in dataSet.Tables[5].Rows)
                {
                    objRoom = new ClassRoom();
                    objRoom.ClassRoomId = Convert.ToInt64(row["ClassRoomId"]);
                    objRoom.Name = Convert.ToString(row["Name"]);
                    classRoomList.Add(objRoom);
                }

            }
            schedule.OrganizationList = new SelectList(listOrganizations, "OrganizationId", "OrganizationName", schedule.OrganizationId);
            schedule.CourseList = new SelectList(courseList, "CourseId", "CourseName", schedule.CourseId);
            schedule.ClassList = new SelectList(classList, "ClassId", "ClassName", schedule.ClassId);
            schedule.SubjectList = new SelectList(subjectList, "SubjectId", "SubjectName", schedule.SubjectId);
            schedule.DepartmentList = new SelectList(departmentList, "DepartmentId", "DepartmentName", schedule.DepartmentId);
            schedule.ClassRoomList = new SelectList(classRoomList, "ClassRoomId", "Name", schedule.ClassRoomId);
            List<SelectListItem> daysList = Enum.GetValues(typeof(StudentTracker.Core.Utilities.Days)).Cast<StudentTracker.Core.Utilities.Days>().Select(v => new SelectListItem
            {
                Text = v.ToString(),
                Value = ((int)v).ToString()
            }).ToList();
            schedule.DayList = new SelectList(daysList, "Value", "Text");

            return schedule;
        }
Exemplo n.º 6
0
        public Staff LoadStaffLists(string userRole, long organizationId = -1, long scheduleId = -1)
        {
            Staff objStaff = null;
            if (scheduleId != -1)
            {
                //objStaff = this.GetSchedule(scheduleId);
            }
            if (objStaff == null)
            {
                objStaff = new Staff();
            }
            //list class objects
            List<Organization> listOrganizations = new List<Organization>();
            List<Course> courseList = new List<Course>();
            List<Class> classList = new List<Class>();
            List<Subject> subjectList = new List<Subject>();
            List<Department> departmentList = new List<Department>();
            List<Section> sectionList = new List<Section>();

            //class objects
            Organization objOrganization = null;
            Course objCourse = null;
            Class objClass = null;
            Subject objSubject = null;
            Department objDep = null;
            Section objSection = null;

            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["StudentContext"].ConnectionString);
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            using (SqlCommand cmd = new SqlCommand("usp_getSchedules", con))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@userRole", SqlDbType.VarChar, 50).Value = userRole;
                cmd.Parameters.Add("@organizationId", SqlDbType.BigInt).Value = objStaff.OrganizationId;
                cmd.Parameters.Add("@courseId", SqlDbType.BigInt).Value = objStaff.CourseId;
                cmd.Parameters.Add("@departmentId", SqlDbType.BigInt).Value = objStaff.DepartmentId;
                cmd.Parameters.Add("@classId", SqlDbType.BigInt).Value = objStaff.ClassId;
                cmd.Parameters.Add("@createdByOrganization", SqlDbType.BigInt, 50).Value = organizationId;

                SqlDataAdapter adp = new SqlDataAdapter();
                adp.SelectCommand = cmd;
                DataSet dataSet = new DataSet();
                adp.Fill(dataSet);

                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    objOrganization = new Organization();
                    objOrganization.OrganizationId = Convert.ToInt64(row["OrganizationId"]);
                    objOrganization.OrganizationName = Convert.ToString(row["OrganizationName"]);
                    listOrganizations.Add(objOrganization);
                    if (userRole != "SiteAdmin")
                    {
                        objStaff.OrganizationName = objOrganization.OrganizationName;
                    }
                }

                foreach (DataRow row in dataSet.Tables[1].Rows)
                {
                    objCourse = new Course();
                    objCourse.CourseId = Convert.ToInt64(row["CourseId"]);
                    objCourse.CourseName = Convert.ToString(row["CourseName"]);
                    courseList.Add(objCourse);
                }

                foreach (DataRow row in dataSet.Tables[2].Rows)
                {
                    objClass = new Class();
                    objClass.ClassId = Convert.ToInt64(row["ClassId"]);
                    objClass.ClassName = Convert.ToString(row["ClassName"]);
                    classList.Add(objClass);
                }

                foreach (DataRow row in dataSet.Tables[3].Rows)
                {
                    objSubject = new Subject();
                    objSubject.SubjectId = Convert.ToInt64(row["SubjectId"]);
                    objSubject.SubjectName = Convert.ToString(row["SubjectName"]);
                    subjectList.Add(objSubject);
                }

                foreach (DataRow row in dataSet.Tables[4].Rows)
                {
                    objDep = new Department();
                    objDep.DepartmentId = Convert.ToInt64(row["DepartmentId"]);
                    objDep.DepartmentName = Convert.ToString(row["DepartmentName"]);
                    departmentList.Add(objDep);
                }

                foreach (DataRow row in dataSet.Tables[6].Rows)
                {
                    objSection = new Section();
                    objSection.SectionId = Convert.ToInt32(row["SectionId"]);
                    objSection.SectionName = Convert.ToString(row["SectionName"]);
                    sectionList.Add(objSection);
                }

            }
            objStaff.OrganizationList = new SelectList(listOrganizations, "OrganizationId", "OrganizationName", objStaff.OrganizationId);
            objStaff.CourseList = new SelectList(courseList, "CourseId", "CourseName", objStaff.CourseId);
            objStaff.ClassList = new SelectList(classList, "ClassId", "ClassName", objStaff.ClassId);
            objStaff.SubjectList = new SelectList(subjectList, "SubjectId", "SubjectName", objStaff.SubjectId);
            objStaff.DepartmentList = new SelectList(departmentList, "DepartmentId", "DepartmentName", objStaff.DepartmentId);
            objStaff.SectionList = new SelectList(sectionList, "SectionId", "SectionName", objStaff.SectionId);
            return objStaff;
        }