public static Tuple <decimal?, decimal?> GetPriceWithCoefficient(decimal?price, bool isTrack, decimal coefficient) { if (price.HasValue && !isTrack) { var newPrice = (decimal?)OrderDetail.FloorToFifty(price.Value * coefficient); return(Tuple.Create(newPrice, newPrice)); } return(OnePrice(price)); }
public static string DiscountPrice(short?discount, decimal?price) { if (discount.HasValue && price > 0) { var priceWithDiscount = OrderDetail.FloorToFifty( price.Value * (decimal)(1.0 - discount / 100.0)); return(OldNewPrice(price, priceWithDiscount)); } return(price.MoneyString()); }
public static string TrackPrice(this CommonCourseListItemVM courseListItemVM, string priceType, decimal?newPrice) { var realFullPrice = courseListItemVM.GetTrackFullPrice(priceType); var pt = PriceTypes.IsCorp(priceType) ? PriceTypes.Corporate : PriceTypes.Main; var ppPrice = courseListItemVM.GetTrackFullPrice(pt); var intraExtraFullPrice = newPrice * ((decimal)1.8); var fullPrice = PriceTypes.IsIntraExtra(priceType) ? (ppPrice > 0 && ppPrice <= intraExtraFullPrice ? OrderDetail.FloorToFifty(((decimal)ppPrice) * (decimal)0.95) : intraExtraFullPrice) : realFullPrice; return(Htmls2.OldNewPrice(fullPrice, newPrice)); }
PriceView CreatePrice(List <PriceView> prices, string courseTC, string fromType, string toType, Group group) { var price = prices.FirstOrDefault(x => x.PriceType_TC == fromType && x.Track_TC == null); if (price == null) { return(null); } var newPrice = OrderDetail.FloorToFifty((price.Price * (100 - group.Discount.Value)) / 100); var priceType = new PriceType { PriceType_TC = toType, PriceListType_TC = PriceListTypes.Common }; return(new PriceView { Course_TC = courseTC, Price = newPrice, PriceType_TC = toType, PriceType = priceType }); }
public CourseBaseVM.SecondCourseDiscount SecondCourse(string courseTC, CourseLink course) { if (course == null) { return(null); } var price = PriceService.GetPriceByType(courseTC, PriceTypes.Main, null); var secondPrice = PriceService.GetPriceByType(course.CourseTC, PriceTypes.Main, null); if (!secondPrice.HasValue || !price.HasValue) { return(null); } var authTypeTC = CourseService.GetValues(course.CourseTC, x => x.AuthorizationType_TC); var discountPercent = AuthorizationTypes.GetSecondCourseDiscount(authTypeTC); var secondpriceWithDiscount = OrderDetail.FloorToFifty(secondPrice.Value * (1.0m - discountPercent / 100.0m)); return(new CourseVM.SecondCourseDiscount { SecondCourse = course, Discount = (secondPrice.Value - secondpriceWithDiscount), SumWithDiscount = secondpriceWithDiscount + price.Value }); }
private TagList GetPriceRows(CourseBaseVM model, bool hasWebinar, bool hasIntraExtra, short?monDiscount) { var unlimitPrice = model.UnlimitPrice; var price = model.GetPrice(PriceTypes.PrivatePersonWeekend); var orgPrice = model.GetPrice(PriceTypes.Corporate); var intraExtraPrice = model.GetPrice(PriceTypes.IntraExtra); var intraExtraOrgPrice = model.GetPrice(PriceTypes.IntraExtraOrg); var orgTitle = "Организации"; if (CourseTC.MsVoucher.Contains(model.Course.Course_TC)) { orgTitle += br.ToString() + span["(Данный курс можно", br, "оплатить ваучерами ", br, Anchor("/news/2297", "Software Assurance"), ")"] .Style("font-size:10px;color:black;font-weight:normal;"); } var ppTitle = "Частные лица"; if (CourseTC.CiscoPrepay.Contains(model.Course.Course_TC)) { ppTitle += br.ToString() + span["По предоплате"] .Style("font-size:10px;color:grey;"); } var webinarPrice = model.GetPrice(PriceTypes.Webinar); Func <decimal?, string> getFirstPayment = x => x.HasValue ? (OrderDetail.FloorToFifty(x.Value * CommonConst.FirstPaymentPercent)).MoneyString() : null; var firstPayment = model.Course.IsTrackBool ? TableRow(td.Class("td_entrant")[Anchor(SimplePages.FullUrls.FirstPaymentNews, "Первый взнос (для частных лиц)").Style("color:red;")], td[getFirstPayment(price)], td[getFirstPayment(price)], hasIntraExtra ? td[getFirstPayment(intraExtraPrice)] : null, hasWebinar ? td[getFirstPayment(webinarPrice)] : null, unlimitPrice.HasValue ? td : null, td.Class("last_td")).Style("color:red;") : null; return (l( TableRow(td.Class("td_entrant")[ppTitle], td[Htmls2.DiscountPrice(monDiscount, price)], td[price.MoneyString()], hasIntraExtra ? td[intraExtraPrice.MoneyString()] : null, hasWebinar ? td[GetWebinarPriceBlock(model)] : null, unlimitPrice.HasValue ? td[ SimpleLinks.Unlimited(unlimitPrice > 0 ? unlimitPrice.MoneyString() : "Бесплатно")] : null, td.Class("last_td")[ Html.AddToCart(model.Course, priceTypeTC: PriceTypes.PrivatePersonWeekend)]), TableRow(td.Class("td_entrant")[orgTitle], td[orgPrice.MoneyString()], td[orgPrice.MoneyString()], hasIntraExtra ? td[intraExtraOrgPrice.MoneyString()] : null, hasWebinar ? td[model.GetPrice(PriceTypes.WebinarOrg).MoneyString()] : null, unlimitPrice.HasValue ? td[""] : null, td.Class("last_td")[ Html.AddToCart(model.Course, priceTypeTC: PriceTypes.Corporate)]), firstPayment )); }
public string GetCsv() { var allPrices = PriceViewService.GetAll(x => x.Track_TC == null).ToList() .GroupByToDictionary(x => x.Course_TC, x => x); var allGroups = GroupService.GetAll().PlannedAndNotBegin() .Where(x => x.Color_TC == Colors.Yellow && x.Course.IsActive) .OrderBy(x => x.DateBeg).ToList().GroupByToDictionary(x => x.Course_TC, x => x); var result = new List <List <string> >(); CourseService.LoadWith(x => x.CourseContents, x => x.AuthorizationType); var courses = CourseService.GetAll().Where(x => x.IsActive && !CourseTC.HalfTrackCourses.Contains(x.Course_TC) && !x.IsTrack.Value).OrderBy(x => x.Course_ID).ToList(); foreach (var course in courses) { var courseTC = course.Course_TC; var row = new List <string>(); var prices = allPrices.GetValueOrDefault(courseTC) ?? new List <PriceView>(); var isWebinar = GetPrice(PriceTypes.Webinar, prices) > 0; var groupList = allGroups.GetValueOrDefault(courseTC) ?? new List <Group>(); row.Add(courseTC); row.Add(course.Name); row.Add(((int)course.BaseHours) + " ак.ч."); row.Add(course.AuthorizationType.GetOrDefault(x => x.AuthorizationName)); row.Add(course.IsProjectAllowed ? "П" : ""); row.Add(isWebinar ? "В" : ""); var description = course.Description; row.Add(ClearnText(description)); var prerequisete = course.CoursePrerequisites.Select( x => (x.Text + " " + x.RequiredCourse.GetOrDefault(z => z.Name)).Trim()).Where(x => x != null).JoinWith(";"); row.Add(ClearnText(prerequisete)); row.Add(ClearnText(course.OnComplete)); var contents = course.CourseContents.OrderBy(x => x.ModuleNumber) .Select(x => "Модуль " + x.ModuleNumber + ". " + x.ModuleName) .JoinWith(";"); row.Add(ClearnText(contents)); Func <string, bool> addPrice = type => { var price = GetPrice(type, prices); if (type == PriceTypes.PrivatePersonWeekend) { var discount = NearestGroupSet.HasMorningDiscount(groupList); var morningPrice = discount.HasValue ? OrderDetail.FloorToFifty( (price * (100 - discount.Value)) / 100) : price; row.Add(morningPrice > 0 ? morningPrice.ToString() : ""); } row.Add(price > 0 ? ((int)price).ToString() : ""); return(price > 0); }; var types = _.List(PriceTypes.PrivatePersonWeekend, PriceTypes.Corporate); var hasPrice = false; foreach (var prefix in _.List("")) { foreach (var type in types) { hasPrice |= addPrice(prefix + type); } } addPrice(PriceTypes.Webinar); if (hasPrice) { var groups = groupList .Select(DateInterval).Distinct().JoinWith(" "); row.Add(groups); row.Add(groupList.Any(x => x.IsOpenLearning) ? "О" : ""); var certs = new CourseVM { Course = course } .Certificates.Select(x => x.Name) .JoinWith(";"); row.Add(certs); result.Add(row); } } var csv = result.Select(x => x.Select(y => y .GetOrDefault(z => z.Replace('\t', ' ').Trim()))); return(CsvUtil.Render(csv)); }