示例#1
0
 public void Insert(FacultyInfo model)
 {
     if (model != null)
     {
         _facultyRepository.Insert(model);
     }
 }
示例#2
0
 public void Update(FacultyInfo model)
 {
     if (model != null)
     {
         _facultyRepository.Update(model);
     }
 }
示例#3
0
        public ActionResult Create(FacultyInfo facultyinfo)
        {
            try
            {
                facultyinfo.EntryBy   = User.Identity.Name;
                facultyinfo.EntryDate = DateTime.Now;


                if (ModelState.IsValid)
                {
                    db.FacultyInfoes.Add(facultyinfo);
                    db.SaveChanges();

                    TempData["ok"] = "ok";

                    TempData["message"] = "<span class=\"color-green\">" + facultyinfo.FacultyName + " Successfully Saved!</span>";
                    return(RedirectToAction("Index"));
                }

                ViewBag.Message = "<span class=\"color-red\">One more validation Error.</span>";
                return(View(facultyinfo));
            }
            catch (Exception ex)
            {
                TempData["message"] = "<span class=\"color-red\">" + ex.InnerException.Message + "</span>";
                return(RedirectToAction("Index"));
            }
        }
 public HttpResponseMessage Put(int id, [FromBody] FacultyInfo faculty)
 {
     try
     {
         using (FacultyDataEntities entities = new FacultyDataEntities())
         {
             var entity = entities.FacultyInfoes.FirstOrDefault(e => e.id == id);
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "The faculty with id :" + id.ToString() + " Not found to update"));
             }
             else
             {
                 entity.name  = faculty.name;
                 entity.phone = faculty.phone;
                 entity.dept  = faculty.dept;
                 entities.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK, entity));
             }
         }
     }
     catch (Exception e)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
     }
 }
示例#5
0
        public IHttpActionResult Insert(FacultyInfoViewModel model)
        {
            if (model != null)
            {
                FacultyInfo data = new FacultyInfo
                {
                    Id                 = model.Id,
                    Name               = model.Name,
                    History            = model.History,
                    Mission            = model.Mission,
                    Vission            = model.Vission,
                    Address            = model.Address,
                    Phone              = model.Phone,
                    FaxNo              = model.FaxNo,
                    Email              = model.Email,
                    ApplicationUserrId = model.DeanId,
                    DeanMessage        = model.DeanMessage,
                    UniversityInfoId   = model.UniversityId
                };
                _facultyInfo.Insert(data);
                return(Ok(data));
            }

            return(NotFound());
        }
示例#6
0
        public ActionResult DeleteConfirmed(int id)
        {
            FacultyInfo facultyinfo = db.FacultyInfoes.Find(id);

            db.FacultyInfoes.Remove(facultyinfo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#7
0
        public FacultyInfo GetById(int empId)
        {
            FacultyInfo result = null;

            if (empId != null)
            {
                result = _facultyRepository.GetById(c => c.Id == empId);
            }

            return(result);
        }
示例#8
0
        // GET: /Faculty/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FacultyInfo facultyinfo = db.FacultyInfoes.Find(id);

            if (facultyinfo == null)
            {
                return(HttpNotFound());
            }
            return(View(facultyinfo));
        }
示例#9
0
        // GET: /Faculty/Edit/5
        public ActionResult Edit(int?id)
        {
            try
            {
                FacultyInfo facultyinfo = db.FacultyInfoes.Find(id);

                return(View(facultyinfo));
            }
            catch (Exception ex)
            {
                TempData["message"] = "<span class=\"color-red\">" + ex.Message + "</span>";
                return(RedirectToAction("Index"));
            }
        }
示例#10
0
        /// <summary>
        /// This function makes a request to the server to get the faculty's information.
        /// </summary>
        public void GetFacultyInfo()
        {
            FacultyInfo responseFaculty;

            /// Gets the faculty information here.
            HttpClient client = NetworkClient.getInstance().getHttpClient();

            string requestURI = BaseConnection.g_facultyString + "/" + m_userEmail + "/";

            try
            {
                /// List data response. This is the blocking call.
                var response = client.GetAsync(requestURI).Result;

                /// Checks if it is successfully gotten. If yes,
                /// then it puts the information to the screen to display.
                if (response.IsSuccessStatusCode)
                {
                    responseFaculty = response.Content.ReadAsAsync <FacultyInfo>().Result;

                    // Rewrite the information in the labels
                    firstNameLabel.Text = responseFaculty.FirstName;
                    lastNameLabel.Text  = responseFaculty.LastName;
                    educationLabel.Text = responseFaculty.Education + " in " + responseFaculty.Concentration;

                    departmentLabel.Text = responseFaculty.Department == "" ? "" : "Department of " + responseFaculty.Department;

                    addressLabel.Text  = responseFaculty.StreetAdd1 == "" ? "" : responseFaculty.StreetAdd1 + "\n";
                    addressLabel.Text += responseFaculty.StreetAdd2 == "" ? "" : responseFaculty.StreetAdd2 + "\n";
                    addressLabel.Text += responseFaculty.State == "" ? "" : responseFaculty.State + ", ";
                    addressLabel.Text += responseFaculty.Zip == "" ? "" : responseFaculty.Zip + "\n";

                    contactLabel.Text = m_userEmail + " " + responseFaculty.Phone;

                    m_faculty = responseFaculty;
                }
                else
                {
                    m_faculty = null;
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                Worker.printServerError(this);
            }
        }
示例#11
0
    public static void Editfaculty(FacultyInfo _faculty)
    {
        SqlConnection con = ConnectionHelper.GetConnection();
        string sp = "USP_Update_Faculty";
        SqlCommand cmd = new SqlCommand(sp, con);
        cmd.Parameters.Add(new SqlParameter("@FacultyID",_faculty.FacultyID));
        cmd.Parameters.Add(new SqlParameter("@FacultyName",_faculty.FacultyName));
        cmd.CommandType=CommandType.StoredProcedure;

        try{
            cmd.ExecuteNonQuery();
        }
       catch(Exception ex)
        {
           throw ex;
       }
    }
示例#12
0
        public IActionResult GetAllFacultyInfo()
        {
            try
            {
                var allFaculty = _repository.Faculty.GetAllFaculty();

                allFacultyInfo = new List <FacultyInfo>();

                foreach (Faculty current in allFaculty)
                {
                    facultyInfoObject = new FacultyInfo
                    {
                        Faculty_Id     = current.Faculty_Id,
                        Faculty_Status = current.Faculty_Status,
                        User_Id        = current.User_Id,
                    };

                    var user = _repository.Users.GetUserById(current.User_Id);

                    facultyInfoObject.Last_Name  = user.Last_Name;
                    facultyInfoObject.First_Name = user.First_Name;
                    facultyInfoObject.Birth_Date = user.Birth_Date;
                    facultyInfoObject.Address    = user.Address;
                    facultyInfoObject.EMail      = user.EMail;
                    facultyInfoObject.Dept_Id    = user.Dept_Id;
                    facultyInfoObject.Type_Code  = user.Type_Code;
                    facultyInfoObject.User_Id    = user.User_Id;
                    facultyInfoObject.Start_Date = user.Start_Date;

                    allFacultyInfo.Add(facultyInfoObject);

                    _logger.LogInfo(facultyInfoObject.ToString());
                }


                _logger.LogInfo($"Returned all faculty from database. " + Enumerable.Count(allFaculty));


                return(Ok(allFacultyInfo.OrderBy(ow => ow.Start_Date)));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside GetAllFacultyInfo action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
        }
示例#13
0
        public IActionResult GetFacultyByDepartmentId(int id)
        {
            var allFaculty = _repository.Faculty.GetAllFaculty();

            allFacultyInfo = new List <FacultyInfo>();

            foreach (Faculty current in allFaculty)
            {
                facultyInfoObject = new FacultyInfo
                {
                    Faculty_Id     = current.Faculty_Id,
                    Faculty_Status = current.Faculty_Status,
                    User_Id        = current.User_Id,
                };

                var user = _repository.Users.GetUserById(current.User_Id);

                facultyInfoObject.Last_Name  = user.Last_Name;
                facultyInfoObject.First_Name = user.First_Name;
                facultyInfoObject.Birth_Date = user.Birth_Date;
                facultyInfoObject.Address    = user.Address;
                facultyInfoObject.EMail      = user.EMail;
                facultyInfoObject.Dept_Id    = user.Dept_Id;
                facultyInfoObject.Type_Code  = user.Type_Code;
                facultyInfoObject.User_Id    = user.User_Id;
                facultyInfoObject.Start_Date = user.Start_Date;

                allFacultyInfo.Add(facultyInfoObject);

                _logger.LogInfo(facultyInfoObject.ToString());
            }

            List <FacultyInfo> facultyByDepartment = new List <FacultyInfo>();

            foreach (var current in allFacultyInfo)
            {
                if (current.Dept_Id == id)
                {
                    facultyByDepartment.Add(current);
                }
            }

            _logger.LogInfo("Number of faculty: " + allFacultyInfo.Count);
            return(Ok(facultyByDepartment.OrderBy(ow => ow.Start_Date)));
        }
 public HttpResponseMessage Post([FromBody] FacultyInfo faculty)
 {
     try
     {
         using (FacultyDataEntities entities = new FacultyDataEntities())
         {
             entities.FacultyInfoes.Add(faculty);
             entities.SaveChanges();
             var message = Request.CreateResponse(HttpStatusCode.Created, faculty);
             message.Headers.Location = new Uri(Request.RequestUri + faculty.id.ToString());
             return(message);
         }
     }
     catch (Exception e)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e));
     }
 }
示例#15
0
        public IActionResult GetFacultyInfoById(int id)
        {
            try
            {
                var facultyFromDb = _repository.Faculty.GetFacultyById(id);


                if (facultyFromDb.Equals(null))
                {
                    _logger.LogError($"Faculty with id: {id}, hasn't been found in db.");
                    return(NotFound());
                }


                _logger.LogInfo($"Returned Faculty with id: {id}");
                facultyInfoObject = new FacultyInfo();


                facultyInfoObject.Faculty_Status = facultyFromDb.Faculty_Status;
                facultyInfoObject.Faculty_Id     = facultyFromDb.Faculty_Id;
                facultyInfoObject.User_Id        = facultyFromDb.User_Id;


                var userFromDb = _repository.Users.GetUserById(facultyFromDb.User_Id);
                facultyInfoObject.Last_Name  = userFromDb.Last_Name;
                facultyInfoObject.First_Name = userFromDb.First_Name;
                facultyInfoObject.Birth_Date = userFromDb.Birth_Date;
                facultyInfoObject.Address    = userFromDb.Address;
                facultyInfoObject.EMail      = userFromDb.EMail;
                facultyInfoObject.Dept_Id    = userFromDb.Dept_Id;
                facultyInfoObject.Type_Code  = userFromDb.Type_Code;
                facultyInfoObject.User_Id    = userFromDb.User_Id;
                facultyInfoObject.Start_Date = userFromDb.Start_Date;
                return(Ok(facultyInfoObject));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside GetFacultyInfoById action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
        }
示例#16
0
    public static FacultyInfo getFacultyByID(int id)
    {
        SqlConnection con = ConnectionHelper.GetConnection();
        string sp = "USP_GetFaculty_ByID";
        SqlCommand cmd = new SqlCommand(sp, con);
        cmd.Parameters.Add(new SqlParameter("@ID",id));
        cmd.CommandType = CommandType.StoredProcedure;
        try
        {
            SqlDataReader _Reader = cmd.ExecuteReader();
            _Reader.Read();

            FacultyInfo _faculty = new FacultyInfo();
            _faculty.FacultyID = int.Parse(_Reader["FacultyID"].ToString());
            _faculty.FacultyName = _Reader["FacultyName"].ToString();
            return _faculty;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
示例#17
0
        public ActionResult Edit(FacultyInfo facultyinfo)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(facultyinfo).State = EntityState.Modified;
                    db.SaveChanges();
                    TempData["ok"]      = "ok";
                    TempData["message"] = "<span class=\"color-green\">" + facultyinfo.FacultyName + " Edited Successfully Saved!</span>";
                    return(RedirectToAction("Index"));
                }

                ViewBag.Message = "<span class=\"color-red\">One more validation Error.</span>";
                return(View(facultyinfo));
            }
            catch (Exception ex)
            {
                TempData["message"] = "<span class=\"color-red\">" + ex.Message + "</span>";
                return(RedirectToAction("Index"));
            }
        }
示例#18
0
        /// <summary>
        /// Makes a PUT REST call here for updating the information provided.
        /// </summary>
        /// <param name="a_sender">It holds the sender.</param>
        /// <param name="a_event">It holds the event arguments</param>
        private void submitButton_Click(object a_sender, EventArgs a_event)
        {
            /// Parses the information provided by the user to desired fields in FacultyInfo or StudentInfo object.
            /// Then, it sends it to the server to store the modification.
            if (!m_isStudent)
            {
                /// Put the info into the object.
                FacultyInfo putFaculty = (FacultyInfo)m_userInfo;
                putFaculty.FirstName  = nameController.m_firstName;
                putFaculty.LastName   = nameController.m_lastName;
                putFaculty.Phone      = nameController.m_phone;
                putFaculty.StreetAdd1 = addressController.m_street1;
                putFaculty.StreetAdd2 = addressController.m_street2;
                putFaculty.City       = addressController.m_city;
                putFaculty.State      = addressController.m_state;
                putFaculty.Zip        = addressController.m_zip;

                putFaculty.Education     = extraInfoController.m_degree;
                putFaculty.University    = extraInfoController.m_university;
                putFaculty.Concentration = extraInfoController.m_concentration;
                putFaculty.Department    = extraInfoController.m_extraInfo;

                HttpClient client = NetworkClient.getInstance().getHttpClient();

                string requestURI = BaseConnection.g_facultyString + "/" + putFaculty.Email + "/";

                /// Sends the request to the server to save the changes.
                var response = client.PutAsJsonAsync <FacultyInfo>(requestURI, putFaculty).Result;

                if (response.IsSuccessStatusCode)
                {
                    MetroMessageBox.Show(this, "Amazing! The changes are saved!", "Saved!", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    this.Dispose();
                }
                else
                {
                    Worker.printServerError(this);
                }
            }
            else
            {
                /// Puts the info from input fields into StudentInfo object.
                StudentInfo putStudent = (StudentInfo)m_userInfo;
                putStudent.FirstName     = nameController.m_firstName;
                putStudent.LastName      = nameController.m_lastName;
                putStudent.Phone         = nameController.m_phone;
                putStudent.StreetAdd1    = addressController.m_street1;
                putStudent.StreetAdd2    = addressController.m_street2;
                putStudent.City          = addressController.m_city;
                putStudent.State         = addressController.m_state;
                putStudent.Zip           = addressController.m_zip;
                putStudent.Education     = extraInfoController.m_degree;
                putStudent.Concentration = extraInfoController.m_concentration;
                putStudent.Graduation    = extraInfoController.m_extraInfo;

                HttpClient client = NetworkClient.getInstance().getHttpClient();

                string requestURI = BaseConnection.g_studentString + "/" + putStudent.Email + "/";

                /// Sends the update to the server.
                var response = client.PutAsJsonAsync <StudentInfo>(requestURI, putStudent).Result;

                if (response.IsSuccessStatusCode)
                {
                    MetroMessageBox.Show(this, "Amazing! The changes are saved!", "Saved!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Dispose();
                }
                else
                {
                    Worker.printServerError(this);
                }
            }
        }
示例#19
0
        /// <summary>
        /// This function starts all the controller where the information are modified.
        /// </summary>
        private void InitiateControllers()
        {
            /// Handles the student and faculty differently since the information needed are different.
            if (!m_isStudent)
            {
                /// Starts the desired controllers and adds it to the panel.
                FacultyInfo faculty = (FacultyInfo)m_userInfo;

                if (nameController == null)
                {
                    nameController      = new NameInfoController(faculty.FirstName, faculty.LastName, faculty.Phone);
                    nameController.Dock = DockStyle.Fill;

                    updateInfoPanel.Controls.Add(nameController);
                }
                /// Starts the desired controllers and adds it to the panel.
                if (addressController == null)
                {
                    addressController      = new AddressInfoController(faculty.StreetAdd1, faculty.StreetAdd2, faculty.City, faculty.State, faculty.Zip);
                    addressController.Dock = DockStyle.Fill;

                    updateInfoPanel.Controls.Add(addressController);
                }

                /// Starts the desired controllers and adds it to the panel.
                if (extraInfoController == null)
                {
                    extraInfoController      = new ExtraInfoController(faculty.Education, faculty.University, faculty.Concentration, faculty.Department);
                    extraInfoController.Dock = DockStyle.Fill;

                    updateInfoPanel.Controls.Add(extraInfoController);
                }
            }
            else
            {
                StudentInfo student = (StudentInfo)m_userInfo;

                /// Starts the desired controllers and adds it to the panel.
                if (nameController == null)
                {
                    nameController      = new NameInfoController(student.FirstName, student.LastName, student.Phone);
                    nameController.Dock = DockStyle.Fill;

                    updateInfoPanel.Controls.Add(nameController);
                }

                /// Starts the desired controllers and adds it to the panel.
                if (addressController == null)
                {
                    addressController      = new AddressInfoController(student.StreetAdd1, student.StreetAdd2, student.City, student.State, student.Zip);
                    addressController.Dock = DockStyle.Fill;

                    updateInfoPanel.Controls.Add(addressController);
                }

                /// Starts the desired controllers and adds it to the panel.
                if (extraInfoController == null)
                {
                    extraInfoController      = new ExtraInfoController(student.Education, student.Concentration, student.Graduation);
                    extraInfoController.Dock = DockStyle.Fill;

                    updateInfoPanel.Controls.Add(extraInfoController);
                }
            }
        }
示例#20
0
        public ActionResult IndividualGradeSheet(int?examId, int?Roll, int?DeparmentId)
        {
            try
            {
                double totalGPA = 0;
                int    flag     = 1;

                var           getResult = DDL.GetSingleResult(Roll.Value, examId, DeparmentId, null);
                StudentInfo   student   = db.StudentInfoes.Where(t => t.RollNo == Roll).SingleOrDefault();
                FacultyInfo   facinfo   = db.FacultyInfoes.Where(t => t.Id == DeparmentId).SingleOrDefault();
                List <result> result    = new List <result>();

                // get total Subject from StudentInfoSubject Except optional = Y
                int StudentSubject = db.StudentInfoSubjects.Where(t => t.OptionalSubject != "Y" && t.StudentId == student.Id).Count();


                if (getResult != null)
                {
                    foreach (var item in getResult)
                    {
                        //get is this subjectId is Optional
                        grade _grade = new grade();
                        if (item.PassStatus == "F")
                        {
                            _grade.Grade      = "F";
                            _grade.GradePoint = 0;
                        }
                        else
                        {
                            _grade = getGrade(item.MarksObtain);
                        }

                        if (item.OptionalSubject == "Y")
                        {
                            totalGPA += (_grade.GradePoint - 2) > 0 ? (_grade.GradePoint - 2) : 0;
                        }
                        else
                        {
                            if (flag == 1 && _grade.GradePoint < 1)
                            {
                                flag = 0;
                            }
                            totalGPA += _grade.GradePoint;
                        }

                        result.Add(new result
                        {
                            SubjectName = item.SubjectName,
                            Grade       = _grade.Grade,
                            GradePoint  = Convert.ToString(_grade.GradePoint)
                        });
                    }

                    if (flag == 0)
                    {
                        totalGPA = 0;
                    }
                    else
                    {
                        totalGPA = totalGPA / StudentSubject;
                    }
                }

                string GPA = "";

                if (totalGPA < 1)
                {
                    GPA = "0 " + "(F)";
                }
                else if (totalGPA < 2)
                {
                    GPA = totalGPA.ToString("0.##") + " (D)";
                }
                else if (totalGPA < 3)
                {
                    GPA = totalGPA.ToString("0.##") + " (C)";
                }
                else if (totalGPA < 3.5)
                {
                    GPA = totalGPA.ToString("0.##") + " (B)";
                }
                else if (totalGPA < 4)
                {
                    GPA = totalGPA.ToString("0.##") + " (A-)";
                }
                else if (totalGPA < 5)
                {
                    GPA = totalGPA.ToString("0.##") + " (A)";
                }
                else if (totalGPA < 6)
                {
                    GPA = totalGPA.ToString("0.##") + " (A+)";
                }

                LocalReport      lr = new LocalReport();
                ReportDataSource rd = new ReportDataSource();

                lr.ReportPath = Server.MapPath("~/ReporFile/IndividualGradeSheet.rdlc");

                DataTable dtFDRStatement = ConvertToDataTable(result.ToList());
                rd.Name  = "SingleResult";
                rd.Value = dtFDRStatement;

                ReportParameter[] parameters = new ReportParameter[]
                {
                    new ReportParameter("Name", student.StudentName),
                    new ReportParameter("ClassRoll", Convert.ToString(student.RollNo)),
                    new ReportParameter("Faculty", Convert.ToString(facinfo.FacultyName)),
                    new ReportParameter("GPA", GPA)          // returns "0"  when decimalVar == 0
                };

                lr.SetParameters(parameters);
                lr.DataSources.Add(rd);

                string reportType = "PDF";
                string mimeType;
                string encoding;
                string fileNameExtension;

                string deviceInfo =
                    "<DeviceInfo>" +
                    "  <OutputFormat>PDF</OutputFormat>" +
                    "  <PageWidth>10.5in</PageWidth>" +
                    "  <PageHeight>11in</PageHeight>" +
                    "  <MarginTop>0.5in</MarginTop>" +
                    "  <MarginLeft>1in</MarginLeft>" +
                    "  <MarginRight>1in</MarginRight>" +
                    "  <MarginBottom>0.5in</MarginBottom>" +
                    "</DeviceInfo>";

                Warning[] warnings;
                string[]  streams;
                byte[]    renderedBytes;
                renderedBytes = lr.Render(
                    reportType,
                    deviceInfo,
                    out mimeType,
                    out encoding,
                    out fileNameExtension,
                    out streams,
                    out warnings);

                renderedBytes = lr.Render(reportType);
                string reportName = "IndGradeSheet-Roll" + Convert.ToString(student.RollNo) + ".pdf";
                return(File(renderedBytes, mimeType, reportName));
            }
            catch (Exception ex) {
                ViewBag.Error = ex.Message;
                return(View("Error"));
            }
        }