Esempio n. 1
0
 public SubjectAllocation GetSubjectAllocationData(int id)
 {
     try
     {
         SubjectAllocation subjectAllocation = _appContext.subjectAllocation.Find(id);
         return(subjectAllocation);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
 public int UpdateSubjectAllocation(SubjectAllocation subjectAllocation)
 {
     try
     {
         _appContext.Entry(subjectAllocation).State = EntityState.Modified;
         _appContext.SaveChanges();
         return(1);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
 public int AddSubjectAllocation(SubjectAllocation subjectAllocation)
 {
     try
     {
         _appContext.subjectAllocation.Add(subjectAllocation);
         _appContext.SaveChanges();
         return(1);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 4
0
 public int DeleteSubjectAllocation(int id)
 {
     try
     {
         SubjectAllocation subjectAllocation = _appContext.subjectAllocation.Find(id);
         _appContext.subjectAllocation.Remove(subjectAllocation);
         _appContext.SaveChanges();
         return(1);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 5
0
        public ActionResult Add(SubjectAllocationViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                int Id = vm.ClassStructureId;
                vm.Faculties = _context.Users.Where(u => u.Roles.Any(r => r.RoleId == "7b224a17-17e4-4611-88a9-13004bbda20e"));
                vm.Subjects  = _context.Subjects.Where(s => s.ClassStructureId == Id);
                return(View("SubjectForm", vm));
            }
            var obj = new SubjectAllocation
            {
                FacultyId = vm.FacultyId,
                SubjectId = vm.SubjectId
            };

            _context.SubjectAllocation.Add(obj);
            _context.SaveChanges();

            return(RedirectToAction("Index", "Subject", new { id = vm.ClassStructureId }));
        }
Esempio n. 6
0
 public int Edit([FromBody] SubjectAllocation SubjectAllocation)
 {
     return(_unitOfWork.Subject.UpdateSubjectAllocation(SubjectAllocation));
 }
Esempio n. 7
0
 public int Create([FromBody] SubjectAllocation SubjectAllocation)
 {
     return(_unitOfWork.Subject.AddSubjectAllocation(SubjectAllocation));
 }