public void Init()
        {
            _verifyTokenMock = new Mock<IProcess<VerifyUserLinkedInAccessTokenParams,UserAccessTokenResultViewModel>>();
            _verifyTokenMock.Setup(x => x.Execute(It.IsAny<VerifyUserLinkedInAccessTokenParams>())).Returns(new UserAccessTokenResultViewModel { AccessTokenValid = true });

            _createPositionMock = new Mock<IProcess<CreatePositionParams, PositionDisplayViewModel>>();
            var createCompanyCmd = new CreateCompanyCommand(_serviceFactory.Object);

            _process = new LinkedInPositionSearchProcesses(_context, _verifyTokenMock.Object, createCompanyCmd, _createPositionMock.Object, null);

            // Initialize user with test (but valid) access token data
            _user = new User();
            var oauth = new OAuthData
            {
                Token = "bfcf3fe4-b4d4-4f37-9d32-292ae9d45347",
                Secret = "f66673b2-5877-4fbf-80e0-3826ca9f7eed",
                TokenProvider = TokenProvider.LinkedIn,
                TokenType = TokenType.AccessToken,
            };

            oauth.LinkedInUsers.Add(_user);
            _user.LinkedInOAuthData = oauth;
            _context.Users.Add(_user);
            _context.OAuthData.Add(oauth);
            _context.SaveChanges();
        }
Пример #2
0
        public virtual ActionResult Edit(EditCompanyViewModel model)
        {
            Company company;

            try
            {
                // Determine if this is a new company or not
                if (model.Id == 0)
                {
                    company = new CreateCompanyCommand(_serviceFactory).WithJobSearch(model.JobSearchId)
                                                                          .SetName(model.Name)
                                                                          .SetCity(model.City)
                                                                          .SetIndustry(model.Industry)
                                                                          .SetMetroArea(model.MetroArea)
                                                                          .SetNotes(model.Notes)
                                                                          .SetPhone(model.Phone)
                                                                          .SetState(model.State)
                                                                          .SetZip(model.Zip)
                                                                          .SetWebsite(model.Website)
                                                                          .CalledByUserId(CurrentUserId)
                                                                          .Execute();
                }
                else
                {
                    company = new EditCompanyCommand(_serviceFactory).WithCompanyId(model.Id)
                                                                          .SetName(model.Name)
                                                                          .SetCity(model.City)
                                                                          .SetIndustry(model.Industry)
                                                                          .SetMetroArea(model.MetroArea)
                                                                          .SetNotes(model.Notes)
                                                                          .SetPhone(model.Phone)
                                                                          .SetState(model.State)
                                                                          .SetZip(model.Zip)
                                                                          .SetLeadStatus(model.LeadStatus)
                                                                          .SetWebsite(model.Website)
                                                                          .RequestedByUserId(CurrentUserId)
                                                                          .Execute();
                }

                return RedirectToAction(MVC.Company.Details(company.Id));
            }

            catch (ValidationException ex)
            {
                foreach (var error in ex.Errors)
                    ModelState.AddModelError(error.PropertyName, error.ErrorMessage);

                model.AvailableLeadStatuses = _serviceFactory.GetService<LeadStatusesAvailableForCompaniesQuery>().Execute();
                return View(model);
            }
        }