public bool AddStudentToSection(StudentSectionModel model, ref string errorMessage)
 {
     using (SZPNUWContext context = new SZPNUWContext())
     {
         Sections section = context.Sections.Where(x => x.Id == model.SectionId).FirstOrDefault();
         if (section != null)
         {
             bool result = (from ss in context.Studentssections
                            join s in context.Sections on ss.Sectionid equals s.Id
                            where s.Subcjetsemesterid == section.Subcjetsemesterid && ss.Studentid == model.StudentId
                            select ss).Any();
             if (!result)
             {
                 Studentssections studSec = new Studentssections()
                 {
                     Sectionid = model.SectionId,
                     Studentid = model.StudentId.Value
                 };
                 context.Studentssections.Add(studSec);
                 context.SaveChanges();
                 return(true);
             }
         }
         errorMessage = PortalMessages.CanNotAddStudentToSection;
         return(false);
     }
 }
Exemple #2
0
 public IActionResult UpdateStudentSection([FromBody] StudentSectionModel model)
 {
     if (ModelState.IsValid)
     {
         string errorMessage = string.Empty;
         if (service.UpdateStudentSection(model, ref errorMessage))
         {
             return(Json(new Result(true)));
         }
         return(Json(new Result(errorMessage)));
     }
     return(Json(new Result(ModelState.GetFirstError())));
 }
Exemple #3
0
 public bool UpdateStudentSection(StudentSectionModel model, ref string errorMessage)
 {
     using (SZPNUWContext context = new SZPNUWContext())
     {
         Studentssections studentSection = context.Studentssections.FirstOrDefault(x => x.Id == model.Id);
         if (studentSection != null)
         {
             studentSection.Rating      = model.Rate;
             studentSection.Dateofentry = model.Date;
             context.SaveChanges();
             return(true);
         }
         errorMessage = PortalMessages.NoSuchElement;
         return(false);
     }
 }
Exemple #4
0
        public IActionResult GetSectionStudent([FromQuery] int studentId, int sectionId)
        {
            StudentSectionModel studSec = service.GetSectionStudent(sectionId, studentId);

            return(Json(studSec));
        }
Exemple #5
0
 public bool AddStudentToSection(StudentSectionModel model, ref string errorMessage)
 {
     return(service.AddStudentToSection(model, ref errorMessage));
 }
Exemple #6
0
 public bool UpdateStudentSection(StudentSectionModel model, ref string errorMessage)
 {
     return(service.UpdateStudentSection(model, ref errorMessage));
 }