public ActionResult WithDiscount(string courseTC) { var groups = GroupService.GetGroupsForCourse(courseTC) .Where(x => x.Discount.HasValue && !x.IsOpenLearning).ToList(); var prices = PriceService.GetAllPricesForCourse(courseTC, null); var course = CourseService.GetByPK(courseTC); var actionBlock = new PagePart(string.Empty); if (groups.Any(x => x.Discount == CommonConst.GoldFallDiscount)) { actionBlock = new PagePart( Htmls.HtmlBlock(HtmlBlocks.GoldFallLarge)); } return(BaseView( new PagePart(H.h3[Html.CourseLink(course)].ToString()), actionBlock, new PagePart( Views.Shared.Education.NearestGroupList, new GroupsWithDiscountVM(groups, true) { Course = course, Prices = prices }))); }
private string GetMaxPriceType(Entities.Context.Order order, List <OrderDetail> newOrderDetails) { var orderDetailIDs = newOrderDetails.Select(od => od.OrderDetailID); var trackDetails = order.OrderDetails.Where(od => orderDetailIDs.Contains(od.OrderDetailID)); var prices = new List <PriceView>(); foreach (var orderDetail in trackDetails) { orderDetail.Group_ID = newOrderDetails.FirstOrDefault( od => od.OrderDetailID == orderDetail.OrderDetailID).Group_ID; if (orderDetail.Group_ID == null) { continue; } var group = GroupService.GetPlannedAndNotBegin() .ByPrimeryKey(orderDetail.Group_ID); var priceTypeTC = OrderService.GetPriceTypeForGroup( group, false, order.CustomerType); var price = PriceService.GetAllPricesForCourse(orderDetail.Course_TC, orderDetail.Track_TC).FirstOrDefault(p => p.PriceType_TC == priceTypeTC); if (price != null) { prices.Add(price); } } return(prices.AsQueryable().SelectMax(p => p.Price).PriceType_TC); }
private void UpdatePrices(Order order) { foreach (var detail in order.GetCourseOrderDetails()) { var price = PriceService.GetAllPricesForCourse(detail.Course_TC, detail.Track_TC) .FirstOrDefault(x => x.PriceType_TC == detail.PriceType_TC); if (price != null) { detail.Price = price.Price; } else { order.OrderDetails.Remove(detail); } } foreach (var orderExam in order.OrderExams.ToList()) { var price = ExamService.GetValues(orderExam.Exam_ID, x => x.ExamPrice); if (price.GetValueOrDefault() > 0) { orderExam.Price = price.Value; } else { order.OrderExams.Remove(orderExam); } } }
public void AddTrack(string trackTC, string priceTypeTC) { var order = OrderService.GetOrCreateCurrentOrder(); if (order.OrderDetails.Any(od => od.Track_TC == trackTC)) { return; } if (priceTypeTC == null) { var price = PriceService.GetAllPricesForCourse(trackTC, null).AsQueryable() .GetDefault(); priceTypeTC = price.GetOrDefault(x => x.PriceType_TC); } var courses = CourseService.GetAllForTrack(trackTC); foreach (var course in courses) { var orderDetail = CreateDetail(course.Course_TC, trackTC, priceTypeTC); if (orderDetail == null) { return; } order.OrderDetails.Add(orderDetail); } CleanTestCertsDopUslExamsAndSubmit(order); }
private void UpdateTrackPrices(Entities.Context.Order order, string trackTC, string priceTypeTC, OrderDetail newDetail, string cityTC) { var trackDetails = order.OrderDetails.Where(od => od.Track_TC == trackTC); string pricePrefix = null; if (cityTC != null) { pricePrefix = PriceTypes.GetPrefix(CityService.GetCityPrefix(cityTC)); } foreach (var orderDetail in trackDetails) { if (newDetail != null) { if (order.IsOrganization && newDetail.Count > 0) { orderDetail.Count = newDetail.Count; } orderDetail.OrgStudents = newDetail.OrgStudents; } if (priceTypeTC == string.Empty) { priceTypeTC = pricePrefix + (orderDetail.Order.IsOrganization ? PriceTypes.Corporate : PriceTypes.PrivatePersonWeekend); } var allPricesForCourse = PriceService.GetAllPricesForCourse(orderDetail.Course_TC, orderDetail.Track_TC).AsQueryable(); var price = allPricesForCourse.FirstOrDefault(p => p.PriceType_TC == priceTypeTC); if (price == null) { price = allPricesForCourse.GetDefault(); } orderDetail.Group_ID = null; orderDetail.SeatNumber = null; orderDetail.PriceType_TC = priceTypeTC; orderDetail.City_TC = cityTC; orderDetail.Price = price.Price; } }
public TrackVM GetByUrlName(string urlName) { var track = TrackService.GetByUrlName(urlName); if (track == null) { return(null); } var courseTC = track.Course_TC; // var certifications = CertificationService. // GetAllForCourse(courseTC); var sections = SiteObjectService.GetSingleRelation <Section>(track) .IsActive().ByWebOrder().ToList(); var prices = PriceService.GetAllPricesForCourse(courseTC, null); var courseTCs = _.List(courseTC); courseTCs.AddRange(CourseService.GetActiveTrackCourses().GetValueOrDefault(track.Course_TC) ?? new List <string>()); var certTypes = CourseCertificateService.GetAll(x => courseTCs.Contains(x.Course_TC)) .Select(x => new { x.Course_TC, x.CertType }).Distinct().ToList().Where(x => x.Course_TC != courseTC || x.CertType.CertTypeName.Contains(CertTypes.InterName)) .Select(x => x.CertType).ToList(); var trackDetailsVM = new TrackVM { Certifications = new List <Certification>(), Course = track, Prices = prices, Sections = sections, CertTypeList = certTypes, CompleteCourseCount = StudentInGroupService.CompleteCountForTracks() .GetValueOrDefault(track.ParentCourse_TC) }; return(trackDetailsVM); }
private void UpdateCourse(EditCourseVM model, OrderDetail newDetail, OrderDetail orderDetail) { if (orderDetail.Order.IsOrganization && newDetail.Count > 0) { orderDetail.Count = newDetail.Count; } orderDetail.OrgStudents = newDetail.OrgStudents; var prices = PriceService.GetAllPricesForCourse(orderDetail.Course_TC, orderDetail.Track_TC).AsQueryable(); string resultPriceTypeTC = null; if (!model.CityTC.IsEmpty()) { orderDetail.City_TC = model.CityTC; } if (PriceTypes.IsDistance(model.PriceTypeTC)) { resultPriceTypeTC = model.PriceTypeTC; orderDetail.Group_ID = null; } if (PriceTypes.IsIndividual(model.PriceTypeTC)) { resultPriceTypeTC = model.PriceTypeTC; orderDetail.Group_ID = null; } if (model.PriceTypeTC == string.Empty) { orderDetail.Group_ID = newDetail.Group_ID; if (orderDetail.Group_ID.HasValue) { var group = GroupService.GetByPK(newDetail.Group_ID); resultPriceTypeTC = OrderService.GetPriceTypeForGroup(group, model.IsBusiness, orderDetail.Order.CustomerType); } else { var groupPrices = prices.Where(p => !p.IsDistance && !p.IsIndividual).AsQueryable(); var maxGroupPrice = groupPrices.GetDefault(); if (maxGroupPrice != null) { resultPriceTypeTC = maxGroupPrice.PriceType_TC; } } } if (PriceTypes.Webinars.Contains(model.PriceTypeTC)) { resultPriceTypeTC = model.PriceTypeTC; orderDetail.Group_ID = newDetail.Group_ID; } if (resultPriceTypeTC != null) { orderDetail.PriceType_TC = resultPriceTypeTC; orderDetail.Price = prices.First(p => p.PriceType_TC == resultPriceTypeTC) .Price; } else { var defaultPrice = prices.GetDefault(); orderDetail.PriceType_TC = defaultPrice.PriceType_TC; orderDetail.Price = defaultPrice.Price; } }
public CartVM GetCart(decimal?orderId = null, bool addTrackDiscounts = false) { Entities.Context.Order order = null; Entities.Context.Order planOrder; if (orderId.HasValue) { order = OrderService.GetByPK(orderId.Value); planOrder = OrderService.GetCurrentOrder(true) ?? new Entities.Context.Order(); } else { order = OrderService.GetCurrentOrder() ?? new Entities.Context.Order(); planOrder = OrderService.GetCurrentOrder(true) ?? new Entities.Context.Order(); } var trainer = EmployeeService.AllEmployees().GetValueOrDefault(order.FavoriteTeacher1); var cart = new CartVM(order) { InPlan = new OrderSeparator(planOrder), User = AuthService.CurrentUser, FavTrainer = trainer.GetOrDefault(x => x.FullName) }; if (cart.OnlyIsCompaty && order.CustomerType == OrderCustomerType.PrivatePerson) { UpdateOrder(OrderCustomerType.Organization); } cart.CourseTCHasExtrases = order.OrderDetails.Where(od => od.Track_TC == null && ExtrasService.GetFor(od).Any()).Select(od => od.Course_TC).ToList(); cart.ExtrasTexts = ExtrasService.Texts(); cart.IsNearestGroupOrderDetails = order.OrderDetails.Where(x => x.Group_ID.HasValue && GroupService.GetGroupsForCourse(x.Course_TC) .FirstOrDefault().GetOrDefault(g => g.Group_ID == x.Group_ID)) .Select(x => x.OrderDetailID).ToList(); if (addTrackDiscounts && order.CustomerType != OrderCustomerType.Organization && !cart.OnlyIsCompaty) { var trackInCart = order.OrderDetails.Where(x => x.Track_TC != null).Select(x => x.Track_TC).ToList(); var courseTCs = order.OrderDetails.Where(x => x.Track_TC.IsEmpty()).Select(x => x.Course_TC).ToList(); if (courseTCs.Any()) { var trackCourses = CourseService.GetActiveTrackCourses().Select(x => new { x.Key, CourseCount = x.Value.Intersect(courseTCs).Count() }) .Where(x => x.CourseCount > 0).ToDictionary(x => x.Key, x => x.CourseCount); var trackTCs = trackCourses.Select(x => x.Key).Where(tc => !trackInCart.Contains(tc)).ToList(); var tracks = CourseService.GetAll(x => trackTCs.Contains(x.Course_TC)).ToList(); var trackDiscounts = TrackService.GetTrackDiscounts(tracks) .OrderByDescending(x => trackCourses[x.Track.Course_TC]).ThenBy(x => x.Price); cart.TrackDiscounts = trackDiscounts.ToList(); } var allOrderCourseTCs = order.OrderDetails.Select(x => x.Course_TC).ToList(); cart.WithWebinar = allOrderCourseTCs.Where(x => PriceService.GetAllPricesForCourse(x, null).Any(y => y.IsWebinar)).ToList(); } return(cart); }