public ActionResult TestCertGroup(TestCertGroupVM model) { var studentIds = StudentInGroupService.GetAll(x => x.Group_ID == model.GroupId) .Select(x => x.Student_ID).ToList(); model.UserTests = new List <UserTest>(); if (model.GroupId > 0) { var userIds = UserService.GetAll(x => x.Student_ID.HasValue && studentIds.Contains(x.Student_ID.Value)).Select(x => x.UserID).ToList(); var userTests = UserTestService.GetAll(x => x.TestId == model.TestId && userIds.Contains(x.UserId) && UserTestStatus.PassStatuses.Contains(x.Status)).ToList(); model.UserTests = userTests; } model.Tests = TestService.GetAll(x => x.Status == TestStatus.Active).ToList() .OrderBy(x => x.Name).ToList(); return(View(model)); }
public bool ExistGroup(User user) { if (user.IsStudent) { var last = StudentInGroupService.GetAll(x => x.Student_ID == user.Student_ID) .OrderByDescending(x => x.LastChangeDate).Select(x => new { x.Router_TC, x.Consultant_TC, x.Org_ID }).FirstOrDefault(); if (last == null) { return(false); } return(true); } else { return(false); } }
public List <Banner> FilterBanner(List <Banner> banners) { if (User == null || !User.IsStudent) { return(banners); } var banner = banners.FirstOrDefault(x => Banners.Target.ContainsKey(x.Banner_ID)); if (banner == null) { return(banners); } var directories = Banners.Target[banner.Banner_ID]; var show = StudentInGroupService.GetAll(x => x.Student_ID == User.Student_ID && directories.Contains(x.Group.Course.CourseDirectionA_TC)) .Any(); if (show) { return(_.List(banner)); } return(new List <Banner>()); }
private decimal GetSigId(decimal studentId, decimal groupId) { return(StudentInGroupService.GetAll(x => x.Student_ID == studentId && x.Group_ID == groupId && x.Org_ID == User.Org_ID) .Select(x => x.StudentInGroup_ID).FirstOrDefault()); }
private IQueryable <StudentInGroup> GetOrgSig() { return(StudentInGroupService.GetAll(x => x.Org_ID == User.Org_ID && BerthTypes.AllPaid.Contains(x.BerthType_TC)).OrderByDescending(x => x.StudentInGroup_ID)); }
public void Export(Entities.Context.Order order, bool checkIfExists) { var alreadyInGroups = new List <decimal>(); var groups = order.OrderDetails.Where(x => x.Group_ID.HasValue) .Select(x => new { Group_ID = x.Group_ID.Value, x.PriceType_TC }).ToList(); if (checkIfExists && order.User.Student_ID.HasValue && groups.Any()) { alreadyInGroups = StudentInGroupService.GetAll(x => x.Student_ID == order.User.Student_ID.Value && groups.Contains(new { x.Group_ID, x.PriceType_TC })).Select(x => x.Group_ID).ToList(); } var student = GetOrInsertStudentByUser(order.User, order.OrderID.ToString()); var berthTypeTC = BerthTypes.NotPaid; var studentInGroupRepository = new Repository <StudentInGroup>( new SpecialistContextProvider()); var nextContactDate = DateTime.Today.AddDays(1); if (order.OrderDetails.Any(x => x.Group.GetOrDefault(g => g.DateBeg) == DateTime.Today)) { nextContactDate = DateTime.Today; } var addEduDocs = false; foreach (var orderDetail in order.OrderDetails.Where(x => !alreadyInGroups.Contains(x.Group_ID.GetValueOrDefault()))) { if (!orderDetail.IsTestCert) { addEduDocs = true; } var discount = orderDetail.GetAllDiscountsInPercent(); string presenceTypeTC; if (PriceTypes.IsDistance(orderDetail.PriceType_TC)) { presenceTypeTC = PresenceTypes.Distance; } else if (PriceTypes.Webinars.Contains(orderDetail.PriceType_TC)) { presenceTypeTC = PresenceTypes.Webinar; } else { presenceTypeTC = PresenceTypes.Intramural; } var courseOrderMangerTC = orderDetail.IsTestCert ? Employees.TestCert : Employees.Site; var isFree = orderDetail.Price == 0; var reason = orderDetail.ReasonForLearning; if (orderDetail.IsTestCert) { reason = LearningReasons.Testing; } else if (!(orderDetail.IsTrack || orderDetail.Course.GetOrDefault(x => x.FullHours >= CommonConst.LongCourseHours))) { reason = LearningReasons.Comprehensive; } var studentInGroup = new StudentInGroup { Student_ID = student.Student_ID, Group_ID = orderDetail.CalcGroupId, InputSource_TC = GetInputSource(), PriceType_TC = orderDetail.PriceType_TC, Discount = Math.Round(discount), BerthType_TC = berthTypeTC, Track_TC = orderDetail.Track_TC, SeatNumber = orderDetail.SeatNumber, Employee_TC = Employees.Site, InputDate = DateTime.Now, FavoriteTeacher1 = orderDetail.IsCourseOrder ? order.FavoriteTeacher1 : null, Debt = 100, NextContactDate = nextContactDate, Consultant_TC = courseOrderMangerTC, Router_TC = courseOrderMangerTC, PresenceType_TC = presenceTypeTC, ReasonForLearning = reason, PromoCode = orderDetail.Order.PromoCode, Charge = orderDetail.PriceWithDiscount, IsHungry = PriceTypes.IsBusiness( orderDetail.PriceType_TC) }; ; if (IsPreTestPass(orderDetail)) { studentInGroup.IsEntryTestPassed = true; } if (isFree) { studentInGroup.Debt = 0; studentInGroup.BerthType_TC = BerthTypes.Kons; studentInGroup.NextContactDate = null; } AddSource(order, studentInGroup); foreach (var extras in orderDetail.OrderExtras) { studentInGroup.StudentInGroupExtras.Add( new StudentInGroupExtras { Extras_ID = extras.Extras_ID, StudentInGroup = studentInGroup }); } studentInGroupRepository.InsertAndSubmit(studentInGroup); orderDetail.StudentInGroup_ID = studentInGroup.StudentInGroup_ID; } foreach (var orderExam in order.OrderExams) { decimal groupID = Groups.NotChoiceGroupID; if (orderExam.Group_ID.HasValue) { groupID = orderExam.Group_ID.Value; } var studentInGroup = new StudentInGroup { Student_ID = student.Student_ID, Group_ID = groupID, PriceType_TC = PriceTypes.PrivatePersonWeekend, BerthType_TC = berthTypeTC, Employee_TC = Employees.Site, InputDate = DateTime.Now, InputSource_TC = GetInputSource(), Debt = 100, ReasonForLearning = LearningReasons.Exam, Exam_ID = orderExam.Exam_ID, NextContactDate = nextContactDate, Charge = orderExam.Price, PresenceType_TC = PresenceTypes.Intramural, }; AddSource(order, studentInGroup); studentInGroupRepository.InsertAndSubmit(studentInGroup); orderExam.StudentInGroup_ID = studentInGroup.StudentInGroup_ID; } if (addEduDocs) { new PioneerDataContext().uspAutoEntryPersonalRecords(student.Student_ID, order.EduDocTypeTC); } }