Beispiel #1
0
        public void Test_Create_Invite()
        {
            var userRepo = new UserRepository(database);
            var usr      = userRepo.CreateNew(new User {
                DateCreated = DateTime.Now, Email = "*****@*****.**", Name = "Jaytee"
            });
            var invRepo = new InviteRepository(database, userRepo);
            var project = invRepo.CreateNew(new Project {
                CreatedByUserId = usr.Id, DateCreated = DateTime.Now, Description = "A demo api", Name = "DEMO API"
            });
            var service = new InviteService(invRepo);

            var res = service.CreateInvite(new Core.Data.Payloads.InvitePayload {
                Email = "*****@*****.**", ProjectId = project.Id
            }, Guid.NewGuid()).Result;

            Assert.NotNull(res);
        }
        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));
        }
Beispiel #3
0
        public void Test_Create_Invite_NotFound()
        {
            var userRepo = new UserRepository(database);
            var usr      = userRepo.CreateNew(new User {
                DateCreated = DateTime.Now, Email = "*****@*****.**", Name = "Jaytee"
            });
            var invRepo = new InviteRepository(database, userRepo);
            var project = invRepo.CreateNew(new Project {
                CreatedByUserId = usr.Id, DateCreated = DateTime.Now, Description = "A demo api", Name = "DEMO API"
            });
            var service = new InviteService(invRepo);

            Assert.ThrowsAsync <DocIT.Core.Services.Exceptions.InviteException>(async() => await service.CreateInvite(new Core.Data.Payloads.InvitePayload {
                Email = "*****@*****.**", ProjectId = Guid.NewGuid()
            }, Guid.NewGuid()));
        }