public Employee GetUserManagerTC(User user) { var mainManager = Employees.MainManager; var managerTC = Employees.MainManager; var isOrg = false; 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) { managerTC = GetUserManagerFromOrders(user.UserID); } else { isOrg = last.Org_ID.HasValue; mainManager = Employees.GetMainManager(isOrg); managerTC = isOrg ? last.Consultant_TC : last.Router_TC; } } else { managerTC = GetUserManagerFromOrders(user.UserID); } managerTC = managerTC ?? mainManager; var employee = EmployeeService.GetByPK(managerTC); if (employee.IsDismiss || !employee.SiteVisible) { employee = EmployeeService.GetByPK(mainManager); } return(employee); }
public ActionResult Special(decimal?id) { try { Order order = null; if (id.HasValue) { order = StudentInGroupService.GetOrder(id.Value); if (order == null) { return(Content("Заказ не найден")); } if (order.IsSigPaid) { return(Content("Статус заказа ({0}) ОПЛ ".FormatWith(order.OurOrgOrDefault))); } } if (order != null) { ViewData[Htmls.OfferUrlKey] = Offers()[order.OurOrgOrDefault]; } return(View(order)); } catch (Exception ex) { Logger.Exception(ex, User); return(BaseView(new PagePart("Оплата недоступна"))); } }
public ActionResult SpecialistOrders(string text) { if (System.Web.HttpContext.Current.Request.IsPost()) { var sigIds = Regex.Split(text, @"[^\d]").Where(x => !x.IsEmpty()).Select(decimal.Parse).ToList(); var sources = SourceService.GetAll().Select(x => new { x.Source_ID, x.Name }) .ToDictionary(x => x.Source_ID, x => x.Name); var result = sigIds.GetRows(1000).SelectMany(ids => OrderDetailService.GetAll(x => ids.Contains(x.StudentInGroup_ID.Value)) .Select(x => new{ x.OrderID, x.StudentInGroup_ID }).ToList()) .ToDictionary(x => x.StudentInGroup_ID, x => x.OrderID); var sigs = sigIds.GetRows(1000).SelectMany(ids => StudentInGroupService.GetAll(x => ids.Contains(x.StudentInGroup_ID)) .Select(x => new { x.StudentInGroup_ID, x.StudentInGroupSources }).ToList() ).Select(x => _.List(x.StudentInGroup_ID.ToString(), result.GetValueOrDefault(x.StudentInGroup_ID).NotNullString() ?? x.StudentInGroupSources.Select(y => y.Source_ID).ToList().Select(y => sources[y]).FirstOrDefault())); return(File(StringUtils.Encoding1251.GetBytes(CsvUtil.Render(sigs)), "text/csv", "SpecialistOrders.csv")); } return(View()); }
private List <decimal> GetStudentIds(decimal groupId) { var studentIds = StudentInGroupService .GetAll(x => x.Group_ID == groupId).Select(x => x.Student_ID).ToList(); return(studentIds); }
public ActionResult Start(int id, string courseTC, int?moduleSetId) { var test = TestService.GetFullTest(id); var groupTest = StudentInGroupService.GetUserGroupTest(id); if (groupTest != null && groupTest.AttemptCount.HasValue) { var count = UserTestService.GetUserTests(groupTest) .Count(x => x.UserId == GetUserId(false)); if (count >= groupTest.AttemptCount.Value) { return(BaseView(new PagePart("Вы использовали все попытки для сдачи теста"))); } } var userTests = GetCurrentTests(); var userTest = userTests.FirstOrDefault(x => x.TestId == id && x.UserId == GetUserId(courseTC != null)); if (userTest == null) { var rule = test.TestPassRule; if (groupTest != null) { rule = groupTest.TestPassRule; } if (moduleSetId.HasValue) { rule = TestModuleSetService.GetValues(moduleSetId.Value, x => x.TestPassRule); } var showAnswers = false; // if (User.GetOrDefault(x => x.Student_ID) > 0) { // var paidCourses = StudentService.GetPaidCourseTCs(User.Student_ID.Value); // showAnswers = test.CourseTCSplitList.Intersect(paidCourses).Any(); // } userTest = SaveUserTest(id, test, rule, courseTC, moduleSetId, showAnswers); } var model = new TestRunVM { Test = test, UserTest = userTest }; if (userTest.IsPrerequisite) { var otherPretests = CoursePrerequisiteService.GetTestIds( courseTC).Skip(1).ToList(); if (otherPretests.Any()) { model.OtherPreTestQuestions = GetQuestions(otherPretests).ToList(); } } if (test.TestIds.Any()) { model.OtherPreTestQuestions = GetQuestions(test.TestIds).ToList(); } return(BaseView(new TestRunView(), model)); }
private StudentInGroup GetSig(decimal groupID) { var user = AuthService.CurrentUser; return(StudentInGroupService.GetAll() .FirstOrDefault(x => BerthTypes.AllPaidAndKonsForCourses.Contains(x.BerthType_TC) && x.Student_ID == user.Student_ID && x.Group_ID == groupID)); }
public ActionResult RefreshCertsStudent(decimal id) { var sigs = StudentInGroupService.GetAll(x => x.Student_ID == id).Select(x => x.StudentInGroup_ID).ToList(); sigs.ForEach(UserImages.DeleteAllCerts); UserImages.DeleteAllCerts(id); return(Content("Сертификаты выпускника {0} обновлены".FormatWith(id))); }
public Entities.Context.Order GetByCommonId(string commonOrderId) { var id = Entities.Context.Order.GetIdFromCommon(commonOrderId); var order = id.Item1 ? GetByPK(id.Item2) : StudentInGroupService.GetOrder(id.Item2); return(order); }
public ActionResult SpecialLink(decimal?id) { try { return(View(StudentInGroupService.GetOrder(id.Value))); } catch (Exception ex) { Logger.Exception(ex, User); return(Content("Оплата недоступна")); } }
bool NeedExport(decimal groupId) { if (User == null || !User.IsStudent) { return(true); } return(!StudentInGroupService.GetAll(x => x.Student_ID == User.Student_ID && x.Group_ID == groupId).Any()); }
public List <Employee> GetStudentTrainers(decimal?studentId) { if (studentId.HasValue) { var employees = EmployeeService.AllEmployees(); return(StudentInGroupService.GetAll(x => x.Student_ID == studentId.Value) .Where(x => BerthTypes.AllPaidForCourses.Contains(x.BerthType_TC)) .Select(x => x.Group.Teacher_TC).Distinct().ToList().Select(x => employees.GetValueOrDefault(x)) .Where(x => x != null).OrderBy(x => x.LastName).ToList()); } return(new List <Employee>()); }
public ActionResult RealSpecialist() { StudentInGroupService.LoadWith(x => x.Load(z => z.Student) .And <Student>(z => z.StudentCalc).And <StudentCalc>(z => z.StudentClabCard)); var students = GetOrgSig().Where(x => x.Student.StudentCalc.ВestClabCard_ID.HasValue) .Select(x => x.Student).Distinct().ToList(); var model = new OrgRealSpecialistVM { Students = students.OrderBy(x => x.LastName).ToList() }; return(BaseViewWithModel(new OrgRealSpecialistView(), model)); }
public List <decimal> FilterExcelMaster(List <decimal> studentIds) { if (!studentIds.Any()) { return(studentIds); } var tracks = _.List(CourseTC.ExcelA, CourseTC.ExcelB); var students = StudentInGroupService.GetAll(x => studentIds.Contains(x.Student_ID) && x.BerthType_TC == BerthTypes.Paid && tracks.Contains(x.Track_TC)) .Select(x => x.Student_ID).Distinct().ToList(); return(students); }
public ActionResult Group(decimal id) { GroupService.LoadWith(x => x.Course); var group = GroupService.GetByPK(id); var students = StudentInGroupService.GetAll(x => x.Group_ID == id && x.Org_ID == User.Org_ID).Select(x => x.Student).ToList(); var model = new OrgGroupVM { Students = students, Group = group }; return(BaseViewWithModel(new OrgGroupView(), model)); }
public ActionResult SendGroupTestInfo(int groupInfoId, bool forManager) { GroupInfoService.LoadWith(c => c.Load(x => x.GroupTests).And <GroupTest>(x => x.Test)); var groupInfo = GroupInfoService.GetByPK(groupInfoId); var managerEmail = forManager ? UserService.FirstOrDefault(x => x.CompanyID == groupInfo.CompanyId).Email : null; var studentIds = StudentInGroupService.GetAll(x => x.Group_ID == groupInfo.Group_ID).Select(x => x.Student_ID).ToList(); var users = UserService.GetAll(x => studentIds.Contains(x.Student_ID.Value)).ToList(); var tests = groupInfo.GroupTests.Select(x => Url.TestLink(x.Test).AbsoluteHref()).ToList(); MailService.GroupTestInfo(users, tests, managerEmail); return(OkJson()); }
public ActionResult Student(decimal id) { var student = StudentService.GetByPK(id); var groups = StudentInGroupService.GetAll(x => x.Student_ID == id && x.Org_ID == User.Org_ID).Select(x => x.Group).ToList(); SetCourses(groups); var model = new OrgStudentVM { Student = student, Groups = groups }; return(BaseViewWithModel(new InlineBaseView <OrgStudentVM>(x => new OrgProfileViews(Url).OrgGroups(x.Model.Groups)), model)); }
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 Dictionary <decimal, List <short> > GetReservedSeatNumbers( List <decimal> groupIds) { var reserved = StudentInGroupService.GetAll(x => groupIds.Contains(x.Group_ID) && x.SeatNumber.HasValue).Select(x => new { SeatNumber = x.SeatNumber.Value, x.Group_ID }).ToList() .GroupByToDictionary(x => x.Group_ID, x => x.SeatNumber); foreach (var groupId in groupIds) { if (!reserved.ContainsKey(groupId)) { reserved.Add(groupId, new List <short>()); } } return(reserved); }
public BangesVM GetBadges(UrlHelper url) { var user = UserService .GetByPK(AuthService.CurrentUser.UserID); var hours = user.IsStudent ? StudentInGroupService.GetAll(x => x.Student_ID == user.Student_ID && BerthTypes.AllPaidForCourses.Contains(x.BerthType_TC) && x.Group.DateEnd <= DateTime.Today) .Sum(x => (decimal?)x.Group.Hours).GetValueOrDefault() : 0; var best2016Url = user.IsStudent && Students.Best2016.Contains(user.Student_ID.Value) ? url.Graduate().Urls.Best2016(user.Student_ID.Value) : null; return(new BangesVM { TopBadge = GetTopBadge(user), HasUnlimit = HasUnlimit(user), Best2016Url = best2016Url, LearningHours = hours, }); }
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); } }
ActionResult GetDetailsView(int id, string courseTC, int?moduleSetId) { var test = TestService.GetByPK(id); if (courseTC != null && CoursePrerequisiteService.GetTestIds( courseTC).All(x => x != id)) { return(NotFound()); } if (!StudentInGroupService.CalcTestIsActive(test)) { return(NotFound()); } return(BaseView(Views.TestRun.Details, new TestRunDetailsVM { Test = test, CourseName = DictionaryUtils.GetValueNotDefaultKey( CourseService.GetAllActiveCourseNames(), courseTC), ModuleSetId = moduleSetId, CourseTC = courseTC, })); }
public ActionResult Details(int id) { if (id != 667 && User != null && User.IsRestricted) { return(Redirect("/")); } TestService.LoadWith(x => x.Author); var test = TestService.GetByPK(id); if (test == null) { return(null); } var isActiveCalc = StudentInGroupService.CalcTestIsActive(test); if (!isActiveCalc && (test.Status == TestStatus.Archive || test.CompanyId.HasValue)) { return(null); } var testStat = TestCalcService.GetByPK(id) ?? new TestCalc(); var testStats = _.List( Tuple.Create("Пользователей сдавало", testStat.UserCount), Tuple.Create("Всего попыток", testStat.TryCount), Tuple.Create("Сданных тестов", testStat.PassCount) ); var model = new TestVM { Test = test, NextTests = SiteObjectService.GetSingleRelation <Test>(test) .ToList(), IsActiveCalc = isActiveCalc, PrevTests = SiteObjectService.GetByRelationObject <Test>(test).ToList(), Courses = SiteObjectService.GetSingleRelation <Course>(test).ToList(), Sections = SiteObjectService.GetSingleRelation <Section>(test).ToList(), TestStats = testStats }; return(BaseView(PartialViewNames.Details, model)); }
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>()); }
public bool UpdateLearningReason(Order order) { var orderDetails = order.GetCourseOrderDetails(); if (!orderDetails.Any()) { return(true); } if (orderDetails.Any(x => x.ReasonForLearning != null)) { return(true); } if (order.HasSchool || order.HasEnglish) { SetComprehensiveReason(order); return(true); } if (StudentInGroupService.HasEducationDocument(order.User.Student_ID)) { SetQualProfReason(order); return(true); } return(false); }
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); } }
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)); }
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()); }
public ActionResult SpecialOrg(decimal id) { return(Content(StudentInGroupService.GetOrder(id).OurOrg_TC)); }