public string FromCredit(decimal creditId) { var context = new PioneerDataContext(); StudentInGroupService.LoadWith(x => x.Student, x => x.Group); StudentInGroupService.LoadWith(c => c.Load(x => x.Student, x => x.Group).And <Group>(x => x.Course)); var sig = StudentInGroupService.GetAll(x => x.CreditRequest_ID == creditId).ToList(); var ourOrgTC = sig.Select(x => context.fnGetDefaultOurOrgTC(x.StudentInGroup_ID, null)).ToList(); if (ourOrgTC.Distinct().Count() != 1) { throw new CreditDataException("Кредитование недоступно"); } var inn = OrderCommonConst.AlphaCredit.GetValueOrDefault(ourOrgTC.First()); if (inn == null) { throw new CreditDataException("Кредитование недоступно"); } var price = sig.Sum(x => x.Charge); var dataCheck = CorrectData(sig.Select(x => x.Group.DateBeg).ToList(), price.Value); if (!dataCheck.Item1) { throw new CreditDataException("Некорректная " + (dataCheck.Item2 ? "дата" : "цена")); } var student = sig.First().Student; var rows = sig.Select(ListRow.FromSig); var id = "cred" + creditId; return(CreateXml(inn, id, student.LastName, student.FirstName, student.MiddleName, price, rows)); }
Entities.Context.Order ConvertToOrder(StudentInGroup sig) { if (sig == null) { return(null); } var email = sig.Student.StudentEmails.OrderByDescending(x => x.StudentEmail_ID).FirstOrDefault() .GetOrDefault(x => x.Email.Trim()); if (email.IsEmpty() || email.Contains(" ") || !email.Contains("@")) { email = null; } var orderDetails = new EntitySet <OrderDetail>(); var orderExams = new EntitySet <OrderExam>(); GroupService.LoadWith(x => x.Course); var group = GroupService.GetByPK(sig.Group_ID); if (sig.Exam_ID > 0) { orderExams.Add(new OrderExam { Exam_ID = sig.Exam_ID.Value }); } else { orderDetails.Add(new OrderDetail { Group = group, Course_TC = group.Course_TC, Course = group.Course, Track_TC = sig.Track_TC }); } var order = new Entities.Context.Order { User = new User { FirstName = sig.Student.FirstName, LastName = sig.Student.LastName, SecondName = sig.Student.MiddleName, Email = email }, IsSig = true, OrderID = sig.StudentInGroup_ID, IsSigPaid = sig.BerthType_TC == BerthTypes.Paid, TotalPriceWithDescount = sig.PartialPayment > 0 ? sig.PartialPayment.Value : sig.Charge.GetValueOrDefault(), OrderDetails = orderDetails, OrderExams = orderExams, OurOrg_TC = null, Description = "Оплата спец заказа №" + sig.StudentInGroup_ID }; var context = new PioneerDataContext(); // if (PriceService.DopUslCourses().Contains(group.Course_TC)) { // order.OurOrg_TC = OurOrgs.Bt; // } order.OurOrg_TC = context.fnGetDefaultOurOrgTC(sig.StudentInGroup_ID, null); return(order); }