Ejemplo n.º 1
0
        public void StudentDeleteTest()
        {
            //Creating a Student
            Student student = CreateStudent();

            Assert.AreNotEqual(0, student.RollNumber);

            //Deleting a Student
            student.Modified_By = 2;
            mStudentDataService.DeleteStudent(student.RollNumber);

            //Getting Student details by RollNumber
            StudentDSR studentDSR = new StudentDSR();
            var        expected   = mStudentDataService.GetStudentInfoByRollNumber(studentDSR.roll_number);

            Assert.AreEqual(expected.roll_number, student.RollNumber);
        }
 //Created by Yogalakshmi on 18.07.2013
 /// <summary>
 /// Deletes the student.
 /// </summary>
 /// <param name="student">The student.</param>
 public void DeleteStudent(int rollNumber)
 {
     studentDataService.DeleteStudent(rollNumber);
 }
Ejemplo n.º 3
0
        // Activates when Submit button on admin page is clicked.
        public IActionResult OnPostSubmit()
        {
            AdminDataService IfaceAdmin  = new AdminDataService();
            bool             success     = true;
            bool             defaultCase = false;

            TempData.Keep("Action");
            TempData.Keep("Actiontype");

            // Basic error checking, Need to reset TempData as well
            if (UID == "" || UID == null)
            {
                DisplayMessage = $"Error Occurred due to ID/Prize Field Empty.";
                return(Page());
            }
            if (Action == "" || Action == null)
            {
                DisplayMessage = $"Error Occurred due to Action not specified.";
                return(Page());
            }
            if ((ChangeValue <= 0) && !(Action == "AddAccount" || Action == "CheckBalance" || Action == "DeletePrize" || Action == "DeleteAccount"))
            {
                DisplayMessage = $"Error Occurred due Value <= 0. Please enter a valid number.";
                PointMessage   = $"Could not Complete Action, enter a positive number.";
                return(Page());
            }
            if (Actiontype == "User")
            {
                Student            student      = new Student();
                StudentDataService IfaceStudent = new StudentDataService();
                if ((student = IfaceStudent.GetStudentCampusId(UID)) != null)
                {
                    switch (Action)
                    {
                    case "AddAccount":
                        success      = IfaceAdmin.AddAccount(UID);
                        PointMessage = "Student account added successfully.";
                        break;

                    case "CheckBalance":
                        PointMessage = student.total_points.ToString();
                        break;

                    case "IncreasePoint":
                        success      = IfaceAdmin.IncrementPoints(UID, ChangeValue);
                        PointMessage = $" {student.first_name} {student.last_name} has {IfaceAdmin.CheckPoints(UID).ToString()} Points";
                        break;

                    case "DecreasePoint":
                        success = IfaceAdmin.DecrementPoints(UID, ChangeValue);
                        break;

                    case "SetPoint":
                        success = IfaceAdmin.SetPoints(UID, ChangeValue);
                        break;

                    case "DeleteAccount":
                        success = IfaceStudent.DeleteStudent(student.campus_id);
                        break;

                    default:
                        DisplayMessage = $"Error Occurred due to Action variable undefined.";
                        PointMessage   = $"Could not Complete Action";
                        defaultCase    = true;
                        success        = false;
                        break;
                    }

                    if (success)
                    {
                        if (Action != "DeleteAccount")
                        {
                            PointMessage = $" {student.first_name} {student.last_name} has {IfaceAdmin.CheckPoints(UID).ToString()} Points";
                        }
                        DisplayMessage = $"Transaction success with {student.first_name} {student.last_name}";
                    }
                    else if (defaultCase)
                    {
                        // do Nothing
                    }
                    else
                    {
                        DisplayMessage = $"Action Failed due to database operation issue!";
                        PointMessage   = $"Could not Complete Action";
                    }
                }
                else
                {
                    switch (Action)
                    {
                    case "AddAccount":
                        success      = IfaceAdmin.AddAccount(UID);
                        PointMessage = "Student account added successfully.";
                        break;

                    default:
                        DisplayMessage = $"Error Occurred due to Student not found.";
                        break;
                    }
                }
            }
            else if (Actiontype == "Prize")
            {
                switch (Action)
                {
                case "SetPrize":
                    success = IfaceAdmin.UpdatePrizePoints(UID, ChangeValue);
                    break;

                case "AddPrize":
                    success = IfaceAdmin.AddPrize(UID, ChangeValue);
                    break;

                case "DeletePrize":
                    success = IfaceAdmin.DeletePrize(UID);
                    break;

                default:
                    DisplayMessage = $"Error Occurred due to Action variable undefined.";
                    defaultCase    = true;
                    success        = false;
                    break;
                }
                PrizeIdList    = IfaceAdmin.GetPrizesId();
                PrizeNameList  = IfaceAdmin.GetAllPrizesName();
                PrizeValueList = IfaceAdmin.GetAllPrizesValue();
                if (success)
                {
                    PointMessage = $"Transaction Success with Prize {UID}";
                }
                else if (defaultCase)
                {
                    //Do Nothing
                }
                else
                {
                    DisplayMessage = $"Transaction Failed due to database operation issue! Check if Prize is valid.";
                }
            }
            else
            {
                DisplayMessage = $"Action Type Undefinied!";
            }

            return(Page());
        }