Ejemplo n.º 1
0
        public bool Create(StudentSubjectRelationship model)
        {
            try
            {
                //Initialization empty item
                var item = new StudentSubjectRelationship();

                //Set value for item with value from model
                item.StudentID  = model.StudentID;
                item.SubjectID  = model.SubjectID;
                item.CreateBy   = model.CreateBy;
                item.CreateTime = DateTime.Now;


                //Add item to entity
                context.StudentSubjectRelationships.Add(item);
                //Save to database
                context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 public JsonResult Add(List <string> list, string IDBM)
 {
     foreach (var i in list)
     {
         var sb = studentSubjectService.getByStudentId(Convert.ToInt32(i));
         if (sb == null)
         {
             var model = new StudentSubjectRelationship {
                 StudentID = Convert.ToInt32(i),
                 SubjectID = Convert.ToInt32(IDBM),
                 CreateBy  = Convert.ToInt32(Session["UserId"])
             };
             studentSubjectService.Create(model);
         }
         else
         {
             var model = new StudentSubjectRelationship
             {
                 StudentID = Convert.ToInt32(i),
                 SubjectID = Convert.ToInt32(IDBM),
                 ModifyBy  = Convert.ToInt32(Session["UserId"])
             };
             studentSubjectService.Update(model);
         }
     }
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 3
0
        public async Task Initialize()
        {
            _context.Database.EnsureCreated();

            // Look for any students.
            if (_context.Subjects.Any())
            {
                return;   // DB has been seeded
            }

            var students = new StudentEntity[]
            {
                new StudentEntity {
                    Forename = "Petru", Surname = "Ritivoiu"
                },
                new StudentEntity {
                    Forename = "Horia", Surname = "Popescu"
                }
            };

            var subjects = new SubjectEntity[]
            {
                new SubjectEntity {
                    Name = "PAW"
                },
            };

            var homeworkDescriptions = new HomeworkDescriptionEntity[]
            {
                new HomeworkDescriptionEntity {
                    Subject         = subjects[0], Name = "Proiect PAW 2018", ShortDescription = "Proiect PAW 2018",
                    FullDescription = "Cerinta proiectului poate fi gasita la adresa http://acs.ase.ro/paw",
                    ReflectionFile  = "MockReflectionFile.xml",
                    UnitTestsFile   = "MockUnitTestingFile.cs"
                }
            };

            var studentSubjectRelationship = new StudentSubjectRelationship[]
            {
                new StudentSubjectRelationship {
                    Student = students[0], Subject = subjects[0]
                },
                new StudentSubjectRelationship {
                    Student = students[1], Subject = subjects[0]
                }
            };

            _context.Students.AddRange(students);
            _context.Subjects.AddRange(subjects);
            _context.HomeworkDescriptions.AddRange(homeworkDescriptions);
            _context.StudentSubjects.AddRange(studentSubjectRelationship);

            await _context.SaveChangesAsync();
        }
 public bool Update(StudentSubjectRelationship model)
 {
     try
     {
         if (model == null)
         {
             return false;
         }
         var update = studentSubjectDAL.Update(model);
         return update;
     }
     catch
     {
         return false;
     }
 }
Ejemplo n.º 5
0
        public bool Update(StudentSubjectRelationship model)
        {
            try
            {
                //Initialization empty item
                var item = context.StudentSubjectRelationships.Where(i => i.StudentID == model.StudentID && (i.IsDeleted == false || i.IsDeleted.Equals(null))).FirstOrDefault();

                //Set value for item with value from model
                item.SubjectID  = model.SubjectID;
                item.ModifyBy   = model.ModifyBy;
                item.CreateTime = DateTime.Now;


                //Save change to database
                context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }