Ejemplo n.º 1
0
        public ActionResult AddSeminarWithLink(decimal groupID, bool isIntramural)
        {
            var user  = AuthService.CurrentUser;
            var group = GroupService.GetByPK(groupID);

            if ((group.IsProbWeb || group.IsSeminar) && !group.IsCareerDay && NeedExport(groupID))
            {
                var orderDetail = new OrderDetail {
                    Group_ID     = groupID,
                    PriceType_TC = (isIntramural || !group.WebinarExists)
                                        ? PriceTypes.PrivatePersonWeekend
                                        : PriceTypes.Webinar,
                    OrderExtras = new EntitySet <OrderExtras>()
                };
                var order = new Order()
                {
                    OrderExams   = new EntitySet <OrderExam>(),
                    OrderDetails = new EntitySet <OrderDetail> {
                        orderDetail
                    },
                    User = user
                };
                try {
                    SpecialistExportService.Export(order, true);
                }catch (Exception e) {
                    Logger.Exception(e, User);
                    return(BaseView(new PagePart("Группа заполнена")));
                }
            }
            var seminar = new GroupSeminar(group);

            MailService.SeminarComplete(seminar, Url.ComplexLinkAnchor(group.Complex).AbsoluteHref().ToString());
            return(RedirectToAction <CourseController>(c => c.SeminarComplete(groupID)));
        }
Ejemplo n.º 2
0
        private decimal SaveStudent(string contact, string[] names)
        {
            var firstName = string.Empty;
            var lastName  = "Слушатель";

            if (names.Length == 1)
            {
                firstName = names[0];
            }
            else
            {
                lastName  = names[0];
                firstName = names[1];
            }
            var student = new Student {
                LastName   = lastName,
                FirstName  = firstName,
                WebKeyword = Guid.NewGuid().ToString("N").Substring(0, 10),
                WebLogin   = Guid.NewGuid().ToString("N").Substring(0, 10),
                Sex        = Sex.M,
                Terrain_ID = Cities.Terrains.Moscow
            };

            if (contact.Contains("@"))
            {
                var email        = contact.Trim();
                var studentEmail = StudentEmailService.FirstOrDefault(x => x.Email == email);
                if (studentEmail != null)
                {
                    return(studentEmail.Student_ID);
                }
                studentEmail = SpecialistExportService.CreateStudentEmail(email);
                student.StudentEmails.Add(studentEmail);
            }
            else
            {
                var phone = Regex.Replace(contact, @"[+\s()-]", "");
                if (Regex.IsMatch(phone, @"\d+"))
                {
                    var studentPhone = StudentPhoneService
                                       .FirstOrDefault(x => x.PhoneNumber == phone);
                    if (studentPhone != null)
                    {
                        return(studentPhone.Student_ID);
                    }
                    studentPhone = SpecialistExportService.CreateStudentPhone(null,
                                                                              phone);
                    student.StudentPhones.Add(studentPhone);
                }
            }

            SpecialistExportService.SaveStudnet(student);
            return(student.Student_ID);
        }
Ejemplo n.º 3
0
        public ActionResult Export(int orderID)
        {
            try {
                SpecialistExportService.Export(orderID, false, null);
            }
            catch (Exception e) {
                if (e.Message.StartsWith(CommonTexts.FullGroupError))
                {
                    return(Content("Экспорт невозможен. Группа заполнена"));
                }
                throw;
            }

            return(RedirectBack());
        }
Ejemplo n.º 4
0
        public decimal?CreateOrder(string name, string contact)
        {
            if (name.IsEmpty() || contact.IsEmpty())
            {
                return(null);
            }
            var names = name.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (!names.Any())
            {
                return(null);
            }

            try {
                var studentId = SaveStudent(contact, names);
                return(SpecialistExportService.SaveExpressOrder(studentId));
            }catch (Exception e) {
                Logger.Exception(e, "CreateOrder " + name + " " + contact);
                return(null);
            }
        }
Ejemplo n.º 5
0
        public ActionResult EmailConfirm(string id)
        {
            SimpleRegUserService.EnableTracking();
            var simpleRegUser = SimpleRegUserService.FirstOrDefault(x => x.Token == Guid.Parse(id));

            if (simpleRegUser == null)
            {
                return(NotFound());
            }

            if (UserService.GetAll(x => x.Email == simpleRegUser.Email).Any())
            {
                return(BaseViewWithTitle("Регистрация",
                                         new PagePart("Пользователь с емейлом {0} уже зарегистрирован"
                                                      .FormatWith(simpleRegUser.Email))));
            }

            var user = new User {
                Email     = simpleRegUser.Email,
                FirstName = simpleRegUser.Name,
                LastName  = simpleRegUser.LastName,
                Password  = Membership.GeneratePassword(6, 0),
                Source_TC = simpleRegUser.Source_TC
            };

            UserService.CreateUser(user);
            AuthService.SignIn(user.Email, true);
            OrderService.UpdateSessionOrderUser();

            SimpleRegUserService.DeleteAndSubmit(simpleRegUser);
            var url = simpleRegUser.Url.IsEmpty() ? Url.Profile().Urls.Details() : simpleRegUser.Url;

            MailService.RegistrationComplete(user, null, false);

            SpecialistExportService ses = new SpecialistExportService();

            ses.InsertStudentBySimpleUser(user);
            ShowMessage("Вы успешно зарегистрировались на сайте");
            return(Redirect(url));
        }