public ActionResult ConfirmSection(int id, Tbl_SectionDistribution tbl, Tbl_PreSectionDistribution tbl1) { Tbl_PreSectionDistribution k = _unitOfWork.GetRepositoryInstance <Tbl_PreSectionDistribution>().GetAllRecordsIQueryable().Where(x => x.SectionID == id).FirstOrDefault(); tbl.SectionID = k.SectionID; tbl.SubjectID = k.SubjectID; tbl.SectionName = k.SectionName; tbl.Available = k.Available; tbl.Credit = k.Credit; tbl.Capacity = k.Capacity; tbl.DepartmentID = k.DepartmentID; tbl.SemesterID = k.SemesterID; tbl.Available = k.Available; tbl.Capacity = k.Capacity; tbl.ClassStart = k.ClassStart; tbl.ClassEnd = k.ClassEnd; tbl.Day1 = k.Day1; tbl.Day2 = k.Day2; tbl.Credit = k.Credit; tbl.ClassStart2 = k.ClassStart2; tbl.ClassEnd2 = k.ClassEnd2; tbl.SectionName = k.SectionName; tbl.TeacherID = k.TeacherID; _unitOfWork.GetRepositoryInstance <Tbl_SectionDistribution>().Add(tbl); _unitOfWork.GetRepositoryInstance <Tbl_PreSectionDistribution>().Remove(k); return(RedirectToAction("SectionConfirm")); }
public IHttpActionResult GetClassRoutineOfTeacher([FromUri] String id) { var list = context.Tbl_SectionDistribution.Where(p => p.TeacherID == id); if (list.FirstOrDefault() == null) { return(StatusCode(HttpStatusCode.NoContent)); } else { List <Tbl_SectionDistribution> comments = new List <Tbl_SectionDistribution>(); foreach (var item in list) { Tbl_SectionDistribution pro = new Tbl_SectionDistribution(); pro.SectionID = item.SectionID; pro.SectionName = item.SectionName; pro.Capacity = item.Capacity; pro.SubjectID = item.SubjectID; pro.Day1 = item.Day1; pro.ClassStart = item.ClassStart; pro.ClassEnd = item.ClassEnd; pro.Day2 = item.Day2; pro.ClassStart2 = item.ClassStart2; pro.ClassEnd2 = item.ClassEnd2; pro.SemesterID = item.SemesterID; pro.DepartmentID = item.DepartmentID; pro.Available = item.Available; pro.Credit = item.Credit; pro.IsConfirmed = item.IsConfirmed; pro.Status = item.Status; pro.TeacherID = id; pro.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts/" + id + "/Comments", Method = "GET", Rel = "Self" }); pro.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts/" + id + "/Comments/" + pro.TeacherID, Method = "GET", Rel = "Specific Resource" }); pro.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts/" + id + "/Comments/" + pro.TeacherID, Method = "PUT", Rel = "Resource Edit" }); pro.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts/" + id + "/Comments/" + pro.TeacherID, Method = "DELETE", Rel = "Resource Delete" }); pro.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts/" + id + "/Comments", Method = "POST", Rel = "Resource Create" }); comments.Add(pro); } return(Ok(comments)); } }
public IHttpActionResult PostRegistration([FromUri] string id, [FromBody] Tbl_SectionDistribution sec) { var kl = context.Tbl_SectionDistribution.Where(x => x.SectionID == sec.SectionID).FirstOrDefault(); var sectiondouble = context.Tbl_Registration.Where(x => x.StudentID == id && x.SectionID == sec.SectionID).FirstOrDefault(); var cradit = context.Tbl_Registration.Where(x => x.StudentID == id && x.SemesterID == kl.SemesterID).Sum(x => x.Credit); var take = context.Tbl_SectionDistribution.Where(x => x.SectionID == sec.SectionID).FirstOrDefault(); var l = context.Tbl_SubjectDetails.Where(x => x.SubjectID == take.SubjectID).FirstOrDefault(); // var sid = _unitOfWork.GetRepositoryInstance<Tbl_SectionDistribution>().GetAllRecordsIQueryable().Where(x => x.SectionID == id).FirstOrDefault(); var subj = context.Tbl_SubjectDetails.Where(x => x.SubjectID == take.SubjectID).FirstOrDefault(); var m = context.Tbl_Student.Where(x => x.StudentID == id).FirstOrDefault(); var kal = context.Tbl_Registration.Where(p => p.StudentID == id && p.SubjectName == take.Tbl_SubjectDetails.SubjectName).FirstOrDefault(); var cost = context.Tbl_SemesterCost.Where(p => p.StudentID == id && p.SemesterIID == take.SemesterID).FirstOrDefault(); var semestercount = context.Tbl_SemesterCost.Where(p => p.StudentID == id).Count(); if (sectiondouble != null && cradit.Value > 16 && kal != null) { return(StatusCode(HttpStatusCode.NotFound)); } else { Tbl_Registration tbl = new Tbl_Registration(); tbl.StudentID = id; tbl.SectionID = take.SectionID; tbl.SemesterID = take.SemesterID; tbl.Available = take.Available; tbl.Capacity = take.Capacity; tbl.ClassStart = take.ClassStart; tbl.ClassEnd = take.ClassEnd; tbl.Day1 = take.Day1; tbl.Day2 = take.Day2; tbl.IsValid = false; tbl.SubjectName = l.SubjectName; tbl.Credit = take.Credit; tbl.ClassStart2 = take.ClassStart2; tbl.ClassEnd2 = take.ClassEnd2; tbl.SectionName = take.SectionName; tbl.TeacherID = take.TeacherID; Tbl_MidResult mid = new Tbl_MidResult(); mid.TeacherID = take.TeacherID; // mid.TeacherName = take.Tbl_Teacher1.FirstName + " " + take.Tbl_Teacher1.LastName; mid.StudentID = id; //mid.StudentName = m.FirstName + " " + m.LastName; mid.SectionID = take.SectionID; mid.SubjectID = take.SubjectID; mid.SemesterID = take.SemesterID; Tbl_SemesterCost scost = new Tbl_SemesterCost(); decimal lab = 0; if (cost != null) { if (semestercount % 3 == 0) { var kk = context.Tbl_Expense.Where(x => x.ExpenseName == "DevelopmentFee").FirstOrDefault(); var ll = context.Tbl_Expense.Where(x => x.ExpenseName == "Activity").FirstOrDefault(); scost.Development = kk.Cost; scost.Activity = ll.Cost; } else { scost.Development = 0; scost.Activity = 0; } if (subj.IsLabExist == "yes") { var kla = context.Tbl_Expense.Where(x => x.ExpenseName == "ComputerLab").FirstOrDefault(); lab = (decimal)cost.ComputerLab; scost.ComputerLab = lab + kla.Cost; } else { scost.ComputerLab = 0; } var jl = context.Tbl_Expense.Where(x => x.ExpenseName == "Credit").FirstOrDefault(); var jj = context.Tbl_Expense.Where(x => x.ExpenseName == "Miscellaneous").FirstOrDefault(); int credit = (int)cost.CreditTaken; scost.CreditTaken = credit + take.Credit; scost.StudentID = id; scost.SemesterIID = take.SemesterID; scost.LanguageLab = 0; scost.Miscellaneous = jj.Cost; scost.PreviousDue = 0; scost.ScienceLab = 0; scost.AdmissionFee = cost.AdmissionFee; scost.Studio = 0; scost.AmountPaid = 0; decimal prev = (decimal)cost.Total; scost.Total = prev + (scost.CreditTaken - credit) * jl.Cost + scost.Development + scost.Activity + lab; scost.Due = scost.Total - scost.AmountPaid; var seme = context.Tbl_SemesterCost.Where(x => x.StudentID == id && x.SemesterIID == take.SemesterID).FirstOrDefault(); context.Tbl_SemesterCost.Remove(seme); context.Tbl_SemesterCost.Add(scost); context.SaveChanges(); } else { var jj = context.Tbl_Expense.Where(x => x.ExpenseName == "Miscellaneous").FirstOrDefault(); var uj = context.Tbl_Expense.Where(x => x.ExpenseName == "Admission").FirstOrDefault(); var kk = context.Tbl_Expense.Where(x => x.ExpenseID == 7).FirstOrDefault(); var ll = context.Tbl_Expense.Where(x => x.ExpenseName == "Activity").FirstOrDefault(); scost.SemesterIID = take.SemesterID; scost.StudentID = id; scost.LanguageLab = 0; scost.Miscellaneous = jj.Cost; scost.PreviousDue = 0; scost.ScienceLab = 0; scost.Studio = 0; scost.AmountPaid = 0; scost.AdmissionFee = uj.Cost; scost.CreditTaken = take.Credit; if (semestercount % 3 == 0) { scost.Development = kk.Cost; scost.Activity = ll.Cost; } else { scost.Development = 0; scost.Activity = 0; } if (subj.IsLabExist == "yes") { var kla = context.Tbl_Expense.Where(x => x.ExpenseName == "ComputerLab").FirstOrDefault(); lab = (decimal)cost.ComputerLab; scost.ComputerLab = kla.Cost; } else { scost.ComputerLab = 0; } var jl = context.Tbl_Expense.Where(x => x.ExpenseName == "Credit").FirstOrDefault(); scost.Total = (scost.CreditTaken) * jl.Cost + scost.Development + scost.Activity + lab; context.Tbl_SemesterCost.Add(scost); context.SaveChanges(); } context.Tbl_Registration.Add(tbl); context.Tbl_MidResult.Add(mid); context.SaveChanges(); return(Created(Url.Link("GetRegistrationByStudentID", new { id = tbl.StudentID, id1 = tbl.RegID }), tbl)); } }
public ActionResult RegistrationConfirm(Tbl_Registration tbl, int id, int did, Tbl_SectionDistribution tbl1, Tbl_AttandanceMid atm, Tbl_AttandanceFinal atm1, Tbl_MidResult mid, Tbl_SemesterCost scost) { string a = Session["UserID"].ToString(); var sectiondouble = _unitOfWork.GetRepositoryInstance <Tbl_Registration>().GetAllRecordsIQueryable().Where(x => x.StudentID == a && x.SectionID == id).FirstOrDefault(); var cradit = _unitOfWork.GetRepositoryInstance <Tbl_Registration>().GetListParameter(x => x.StudentID == a && x.SemesterID == did).Sum(x => x.Credit); var take = _unitOfWork.GetRepositoryInstance <Tbl_SectionDistribution>().GetAllRecordsIQueryable().Where(x => x.SectionID == id).FirstOrDefault(); var l = _unitOfWork.GetRepositoryInstance <Tbl_SubjectDetails>().GetAllRecordsIQueryable().Where(x => x.SubjectID == take.SubjectID).FirstOrDefault(); // var sid = _unitOfWork.GetRepositoryInstance<Tbl_SectionDistribution>().GetAllRecordsIQueryable().Where(x => x.SectionID == id).FirstOrDefault(); var subj = _unitOfWork.GetRepositoryInstance <Tbl_SubjectDetails>().GetAllRecordsIQueryable().Where(x => x.SubjectID == take.SubjectID).FirstOrDefault(); var m = _unitOfWork.GetRepositoryInstance <Tbl_Student>().GetAllRecordsIQueryable().Where(x => x.StudentID == a).FirstOrDefault(); var kal = _unitOfWork.GetRepositoryInstance <Tbl_Registration>().GetAllRecordsIQueryable().Where(p => p.StudentID == a && p.SubjectName == take.Tbl_SubjectDetails.SubjectName).FirstOrDefault(); var cost = _unitOfWork.GetRepositoryInstance <Tbl_SemesterCost>().GetAllRecordsIQueryable().Where(p => p.StudentID == a && p.SemesterIID == take.SemesterID).FirstOrDefault(); var semestercount = _unitOfWork.GetRepositoryInstance <Tbl_SemesterCost>().GetAllRecordsIQueryable().Where(p => p.StudentID == a).Count(); if (sectiondouble != null && cradit.Value > 16 && kal != null) { Response.Write("<script>alert('Sorry! u have already taken this subject')</script>"); } else { tbl.StudentID = a; tbl.SectionID = id; tbl.SemesterID = did; tbl.Available = take.Available; tbl.Capacity = take.Capacity; tbl.ClassStart = take.ClassStart; tbl.ClassEnd = take.ClassEnd; tbl.Day1 = take.Day1; tbl.Day2 = take.Day2; tbl.IsValid = false; tbl.SubjectName = l.SubjectName; tbl.Credit = take.Credit; tbl.ClassStart2 = take.ClassStart2; tbl.ClassEnd2 = take.ClassEnd2; tbl.SectionName = take.SectionName; tbl.TeacherID = take.TeacherID; atm.TeacherID = take.TeacherID; atm.SectionID = take.SectionID; atm.SectionName = take.SectionName; atm.SubjectID = take.SubjectID; atm.TeacherName = take.Tbl_Teacher1.FirstName + " " + take.Tbl_Teacher1.LastName; atm.StudentID = a; atm.StudentName = m.FirstName + " " + m.LastName; atm1.TeacherID = take.TeacherID; atm1.SectionID = take.SectionID; atm1.SectionName = take.SectionName; atm1.SubjectID = take.SubjectID; atm1.TeacherName = take.Tbl_Teacher1.FirstName + " " + take.Tbl_Teacher1.LastName; atm1.StudentID = a; atm1.StudentName = m.FirstName + " " + m.LastName; mid.TeacherID = take.TeacherID; // mid.TeacherName = take.Tbl_Teacher1.FirstName + " " + take.Tbl_Teacher1.LastName; mid.StudentID = a; //mid.StudentName = m.FirstName + " " + m.LastName; mid.SectionID = take.SectionID; mid.SubjectID = take.SubjectID; mid.SemesterID = take.SemesterID; decimal lab = 0; if (cost != null) { if (semestercount % 3 == 0) { var kk = _unitOfWork.GetRepositoryInstance <Tbl_Expense>().GetAllRecordsIQueryable().Where(x => x.ExpenseName == "DevelopmentFee").FirstOrDefault(); var ll = _unitOfWork.GetRepositoryInstance <Tbl_Expense>().GetAllRecordsIQueryable().Where(x => x.ExpenseName == "Activity").FirstOrDefault(); scost.Development = kk.Cost; scost.Activity = ll.Cost; } else { scost.Development = 0; scost.Activity = 0; } if (subj.IsLabExist == "yes") { var kl = _unitOfWork.GetRepositoryInstance <Tbl_Expense>().GetAllRecordsIQueryable().Where(x => x.ExpenseName == "ComputerLab").FirstOrDefault(); lab = (decimal)cost.ComputerLab; scost.ComputerLab = lab + kl.Cost; } else { scost.ComputerLab = 0; } var jl = _unitOfWork.GetRepositoryInstance <Tbl_Expense>().GetAllRecordsIQueryable().Where(x => x.ExpenseName == "Credit").FirstOrDefault(); var jj = _unitOfWork.GetRepositoryInstance <Tbl_Expense>().GetAllRecordsIQueryable().Where(x => x.ExpenseName == "Miscellaneous").FirstOrDefault(); int credit = (int)cost.CreditTaken; scost.CreditTaken = credit + take.Credit; scost.StudentID = a; scost.SemesterIID = take.SemesterID; scost.LanguageLab = 0; scost.Miscellaneous = jj.Cost; scost.PreviousDue = 0; scost.ScienceLab = 0; scost.AdmissionFee = cost.AdmissionFee; scost.Studio = 0; scost.AmountPaid = 0; decimal prev = (decimal)cost.Total; scost.Total = prev + (scost.CreditTaken - credit) * jl.Cost + scost.Development + scost.Activity + lab; scost.Due = scost.Total - scost.AmountPaid; _unitOfWork.GetRepositoryInstance <Tbl_SemesterCost>().RemovebyWhereClause(x => x.StudentID == a && x.SemesterIID == take.SemesterID); _unitOfWork.GetRepositoryInstance <Tbl_SemesterCost>().Add(scost); } else { var jj = _unitOfWork.GetRepositoryInstance <Tbl_Expense>().GetAllRecordsIQueryable().Where(x => x.ExpenseName == "Miscellaneous").FirstOrDefault(); var uj = _unitOfWork.GetRepositoryInstance <Tbl_Expense>().GetAllRecordsIQueryable().Where(x => x.ExpenseName == "Admission").FirstOrDefault(); var kk = _unitOfWork.GetRepositoryInstance <Tbl_Expense>().GetAllRecordsIQueryable().Where(x => x.ExpenseID == 7).FirstOrDefault(); var ll = _unitOfWork.GetRepositoryInstance <Tbl_Expense>().GetAllRecordsIQueryable().Where(x => x.ExpenseName == "Activity").FirstOrDefault(); scost.SemesterIID = take.SemesterID; scost.StudentID = a; scost.LanguageLab = 0; scost.Miscellaneous = jj.Cost; scost.PreviousDue = 0; scost.ScienceLab = 0; scost.Studio = 0; scost.AmountPaid = 0; scost.AdmissionFee = uj.Cost; scost.CreditTaken = take.Credit; if (semestercount % 3 == 0) { scost.Development = kk.Cost; scost.Activity = ll.Cost; } else { scost.Development = 0; scost.Activity = 0; } if (subj.IsLabExist == "yes") { var kl = _unitOfWork.GetRepositoryInstance <Tbl_Expense>().GetAllRecordsIQueryable().Where(x => x.ExpenseName == "ComputerLab").FirstOrDefault(); lab = (decimal)cost.ComputerLab; scost.ComputerLab = kl.Cost; } else { scost.ComputerLab = 0; } var jl = _unitOfWork.GetRepositoryInstance <Tbl_Expense>().GetAllRecordsIQueryable().Where(x => x.ExpenseName == "Credit").FirstOrDefault(); scost.Total = (scost.CreditTaken) * jl.Cost + scost.Development + scost.Activity + lab; _unitOfWork.GetRepositoryInstance <Tbl_SemesterCost>().Add(scost); } _unitOfWork.GetRepositoryInstance <Tbl_Registration>().Add(tbl); _unitOfWork.GetRepositoryInstance <Tbl_AttandanceMid>().Add(atm); _unitOfWork.GetRepositoryInstance <Tbl_AttandanceFinal>().Add(atm1); _unitOfWork.GetRepositoryInstance <Tbl_MidResult>().Add(mid); } return(RedirectToAction("Registration", "Student")); }