示例#1
0
 public ActionResult UpdateSorting(List <string> changedTCList,
                                   List <string> allTCList)
 {
     if (changedTCList != null)
     {
         var context = new SpecialistDataContext();
         var courses = context.Courses.Where(c => c.IsActive)
                       .OrderBy(c => c.WebSortOrder)
                       .ToList();
         new CourseSorting(courses, changedTCList, allTCList).Update();
         context.SubmitChanges();
         Thread.Sleep(2000);
     }
     return(Json("done"));
 }
示例#2
0
        public static void ImportExams(IEnumerable <ProviderExam> providerExams,
                                       int vendorID, string examType, int providerId)
        {
            var context = new SpecialistDataContext(PioneerConnectionString);

            foreach (var providerExam in providerExams)
            {
                var exam = context.Exams
                           .FirstOrDefault(e => e.Exam_TC == providerExam.Number);
                if (exam != null)
                {
                    exam.LastChangeDate = DateTime.Now;
                }
                else
                {
                    exam = new Exam {
                        Exam_TC        = providerExam.Number,
                        ExamName       = providerExam.Name,
                        ExamType       = examType,
                        Vendor_ID      = vendorID,
                        LastChangeDate = DateTime.Now
                    };
                    context.Exams.InsertOnSubmit(exam);
                }

                if (!exam.ProviderPrice.HasValue || examType == exam.ExamType)

                /*	if (exam.ExamProviders.All(e => e.Provider_ID != providerId)) {
                 *              exam.ExamProviders.Add(
                 *                      new ExamProvider {
                 *                              Provider_ID = providerId,
                 *                              LastChanger_TC = Employees.Specweb,
                 *                              InputDate = DateTime.Now,
                 *                              Employee_TC = Employees.Specweb,
                 *                              LastChangeDate = DateTime.Now
                 *                      });
                 *      }*/
                /*|| (vendorID == ProviderConst.OracleId && examType == Providers.VueExamType)*/ {
                    exam.ProviderPrice = providerExam.Price;
                    exam.Available     = true;
                    exam.Languages     = providerExam.Languages.Where(l =>
                                                                      ProviderConst.GetPrometricLanguages().Contains(l))
                                         .JoinWith(",");
                }
            }
            context.SubmitChanges();
        }
示例#3
0
        public void Update()
        {
            var context = new PassportDataContext();
            var photos  = context.UserContacts.Where(x => x.ContactTypeID == ContactTypes.VKontakte &&
                                                     x.User.Student_ID > 0)
                          .Select(x => new { x.User.Student_ID, x.Contact })
                          .ToDictionary(x => x.Student_ID.Value, x => GetVkUrl(x.Contact));
            var students    = photos.Keys.ToList();
            var specContext = new SpecialistDataContext();
            var responses   = specContext.GetTable <Response>().Select(x => new { x.RawQuestionnaire.Questionnaire.Student_ID, Response = x })
                              .Where(x => students.Contains(x.Student_ID)).ToList();

            foreach (var response in responses)
            {
                var vkUrl = photos[response.Student_ID];
                if (vkUrl != null)
                {
                    response.Response.PhotoUrl  = vkUrl.Item1;
                    response.Response.SocialUrl = vkUrl.Item2;
                }
            }
            specContext.SubmitChanges();
        }
示例#4
0
        public static List <ExamPrice> UpdateExamPricesFromProviderPrices(bool submit = false)
        {
            var result   = new List <ExamPrice>();
            var context  = new SpecialistDataContext(PioneerConnectionString);
            var currency = context.Currencies
                           .Where(c => c.CurrencyType_TC == "USD").OrderByDescending(c => c.FiscalDate)
                           .First().Rate;
            var exams     = context.Exams.Where(c => c.ProviderPrice != null && c.ProviderPrice > 0).ToList();
            var examCount = exams.Count();
            var i         = 0;

            foreach (var exam in exams)
            {
                if (submit)
                {
                    WriteStatus("Обновление цен", null, i, examCount);
                }
                var price = exam.ProviderPrice.Value * ProviderConst.NdsCoefficient * currency;
                if (exam.ExamType == Providers.VueExamType)
                {
                    price = price * ProviderConst.VueCoefficient;
                }
                var newPrice = price % 10 == 0
                                        ? price
                                        : ((int)(price * (decimal)0.1)) * 10 + 10;
                result.Add(new ExamPrice {
                    Exam = exam,
                    Old  = (int)exam.ExamPrice.GetValueOrDefault(), New = (int)newPrice
                });
                exam.ExamPrice = newPrice;
            }
            if (submit)
            {
                context.SubmitChanges();
            }
            return(result);
        }