Ejemplo n.º 1
0
        public Invite CreateInvite(InviteDataStruct inviteData)
        {
            if (string.IsNullOrWhiteSpace(inviteData.Name) || string.IsNullOrWhiteSpace(inviteData.Surname) || string.IsNullOrWhiteSpace(inviteData.Patronymic))
            {
                throw new BusinessLogicException("Не заполнены ФИО");
            }

            string key = null;

            if (inviteData.State != InviteState.Requested)
            {
                key = Guid.NewGuid().ToString();
            }

            var invite = new Invite()
            {
                Email        = inviteData.Email,
                Facebook     = inviteData.FacebookId,
                Key          = key,
                LiveJournal  = inviteData.LiveJournalId,
                Name         = inviteData.Name,
                Surname      = inviteData.Surname,
                Patronymic   = inviteData.Patronymic,
                State        = (byte)(inviteData.State ?? InviteState.NotSent),
                UserInfo     = inviteData.UserInfo,
                CreationDate = DateTime.Now,
                Phone        = inviteData.Phone
            };

            DataService.PerThread.InviteSet.AddObject(invite);
            DataService.PerThread.SaveChanges();

            return(invite);
        }
Ejemplo n.º 2
0
        public Invite CreateInvite(InviteDataStruct inviteData)
        {
            if (string.IsNullOrWhiteSpace(inviteData.Name) || string.IsNullOrWhiteSpace(inviteData.Surname) || string.IsNullOrWhiteSpace(inviteData.Patronymic))
                throw new BusinessLogicException("Не заполнены ФИО");

            string key = null;
            if(inviteData.State != InviteState.Requested)
                key = Guid.NewGuid().ToString();

            var invite = new Invite()
            {
                Email = inviteData.Email,
                Facebook = inviteData.FacebookId,
                Key = key,
                LiveJournal = inviteData.LiveJournalId,
                Name = inviteData.Name,
                Surname = inviteData.Surname,
                Patronymic = inviteData.Patronymic,
                State = (byte)(inviteData.State ?? InviteState.NotSent),
                UserInfo = inviteData.UserInfo,
                CreationDate = DateTime.Now,
                Phone = inviteData.Phone
            };

            DataService.PerThread.InviteSet.AddObject(invite);
            DataService.PerThread.SaveChanges();

            return invite;
        }
Ejemplo n.º 3
0
 public static Invite CreateInvite(InviteDataStruct inviteData)
 {
     return(_current.CreateInvite(inviteData));
 }
Ejemplo n.º 4
0
        public ActionResult InviteRequest(InviteRequestViewModel model)
        {
            if (ModelState.IsValid)
            {
                var inviteData = new InviteDataStruct()
                {
                    Name = model.Name,
                    Surname = model.Surname,
                    Patronymic = model.Patronymic,
                    Email = model.Email,
                    FacebookId = model.FacebookUrl,
                    LiveJournalId = model.LiveJournalUrl,
                    State = InviteState.Requested,
                    UserInfo = model.UserInfo
                };

                InviteService.CreateInvite(inviteData);

                //todo - сделать вьюху для сообщения "вы успешно послали реквест"
                return RedirectToAction("index", "home", null);
            }

            return View(model);
        }
Ejemplo n.º 5
0
 public static Invite CreateInvite(InviteDataStruct inviteData)
 {
     return _current.CreateInvite(inviteData);
 }
Ejemplo n.º 6
0
        public ActionResult InviteUser(UserInviteUserViewModel model)
        {
            throw new BusinessLogicException("Данный вид регистрации отключен. Для более точной информации свяжитесь с технической поддержкой [email protected]");

            if (!Request.IsAuthenticated)
                throw new AuthenticationException();

            if (!ModelState.IsValid)
                return View(model);

            var referal = DataService.PerThread.BaseUserSet.SingleOrDefault(u => u.Id == model.ReferalId);
            if (referal == null)
                throw new BusinessLogicException("Пользователь не найден!");

            var givenInvitesCount = DataService.PerThread.InviteSet.Count(i => i.Referal.Id == referal.Id);
            if (givenInvitesCount >= ConstHelper.MaxInvitesCount)
                throw new ValidationException("Вы исчерпали лимит приглашений!");

            var allreadyInvitedCount =
                DataService.PerThread.InviteSet.Count(
                    i => i.Email == model.Email && i.State != (byte) InviteState.Blocked);
            if (allreadyInvitedCount != 0)
                throw new ValidationException("Пользователь с таким адресом электропочты уже приглашен!");

            var existedUser =
                DataService.PerThread.BaseUserSet.OfType<User>().SingleOrDefault();
            if (existedUser != null)
                throw new ValidationException("Пользователь с таким адресом электропочты уже зарегистрирован!");

            var inviteData = new InviteDataStruct
                {
                    Name = model.Name,
                    Surname = model.SurName,
                    Patronymic = model.Patronymic,
                    Email = model.Email,
                    UserInfo = model.Info
                };

            var invite = InviteService.CreateInvite(inviteData);
            invite.Referal = referal;

            DataService.PerThread.SaveChanges();
            InviteService.SendInvite(invite.Id);

            //TODO - сделать систему вывода сообщений
            return RedirectToAction("inviteusercomplete");
        }