public SubjectAllocation GetSubjectAllocationData(int id) { try { SubjectAllocation subjectAllocation = _appContext.subjectAllocation.Find(id); return(subjectAllocation); } catch (Exception ex) { throw ex; } }
public int UpdateSubjectAllocation(SubjectAllocation subjectAllocation) { try { _appContext.Entry(subjectAllocation).State = EntityState.Modified; _appContext.SaveChanges(); return(1); } catch (Exception ex) { throw ex; } }
public int AddSubjectAllocation(SubjectAllocation subjectAllocation) { try { _appContext.subjectAllocation.Add(subjectAllocation); _appContext.SaveChanges(); return(1); } catch (Exception ex) { throw ex; } }
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; } }
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 })); }
public int Edit([FromBody] SubjectAllocation SubjectAllocation) { return(_unitOfWork.Subject.UpdateSubjectAllocation(SubjectAllocation)); }
public int Create([FromBody] SubjectAllocation SubjectAllocation) { return(_unitOfWork.Subject.AddSubjectAllocation(SubjectAllocation)); }