Esempio n. 1
0
        public ActionResult Save(StudentResult studentResult)
        {
            try
            {
                ViewBag.Message = studentManager.Save(studentResult);
                IEnumerable<Student> students = studentManager.GetAll;
                IEnumerable<Course> courses = courseManager.GetAll;
                ViewBag.Students = students;
                ViewBag.Courses = courses;

                return View();
                //return RedirectToAction("Index");
            }
            catch (Exception exception)
            {
                ViewBag.Message = exception.InnerException.Message;
                return View();
            }
        }
Esempio n. 2
0
        public int UpdateStudentResult(StudentResult studentResult)
        {
            CommandObj.CommandText = "UPDATE t_StudentResult SET IsStudentActive=1,Grade='"+studentResult.Grade+"' WHERE StudentId='" +
                                     studentResult.StudentId + "' AND CourseId='" + studentResult.CourseId + "'";
            ConnectionObj.Open();

              int i= CommandObj.ExecuteNonQuery();
            ConnectionObj.Close();
            return i;
        }
Esempio n. 3
0
 public int Insert(StudentResult studentResult)
 {
     try
     {
         CommandObj.CommandText = "INSERT INTO t_StudentResult VALUES(@stId,@courseId,@grade,@isStudentActive)";
         CommandObj.Parameters.Clear();
         CommandObj.Parameters.AddWithValue("@stId", studentResult.StudentId);
         CommandObj.Parameters.AddWithValue("@courseId", studentResult.CourseId);
         CommandObj.Parameters.AddWithValue("@grade", studentResult.Grade);
         CommandObj.Parameters.AddWithValue("@isStudentActive", 1);
         ConnectionObj.Open();
         int rowAffected = CommandObj.ExecuteNonQuery();
         return rowAffected;
     }
     catch (Exception exception)
     {
         throw new Exception("Could not save",exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
     }
 }
Esempio n. 4
0
        private bool IsResulExits(StudentResult studentResult)
        {
            StudentResult result =
                GetAllResult.ToList()
                    .Find(st => st.StudentId == studentResult.StudentId && st.CourseId == studentResult.CourseId);
            if (result != null)
            {
                bool st = result.Status;
                if (st)
                {
                    return true;
                }

            }
            return false;
        }
Esempio n. 5
0
        public string Save(StudentResult studentResult)
        {
            StudentResult result =
                GetAllResult.ToList()
                    .Find(st => st.StudentId == studentResult.StudentId && st.CourseId == studentResult.CourseId);
               if (result==null)
               {
               if (studentGateway.Insert(studentResult) > 0)
               {
                   return "Saved sucessfull!";
               }
               return "Failed to save";

               }
            if (result.Status)
            {
                return "This course result already saved";
            }
            if (studentGateway.UpdateStudentResult(studentResult) > 0)
            {
                return "Saved sucessfull!";
            }

            return "This course result already saved";
        }