Example #1
0
        public void CreateEmployer_succeeded_if_Employer_is_valid()
        {
            //arrange
            var Employers = new List <Employer>();
            var uow       = new Mock <IUnitOfWork>();
            var repo      = new Mock <IUserRepository>();

            repo.Setup(r => r.AddEmployer(It.IsNotNull <Employer>()))
            .Callback <Employer>(a => Employers.Add(a))
            .Verifiable();

            uow.Setup(u => u.SaveChanges())
            .ReturnsAsync(1)
            .Verifiable();

            uow.Setup(u => u.UserRepository)
            .Returns(repo.Object)
            .Verifiable();

            var manager = new EmployerManager(uow.Object);
            //act
            var result = manager.Create(new Employer()).Result;

            //assert
            repo.Verify();
            uow.Verify();
            Assert.True(result.Succeeded);
            Assert.Equal(1, Employers.Count);
        }
Example #2
0
        public void UpdateEmployer_succeeded_if_Employer_is_valid()
        {
            //arrange
            var uow  = new Mock <IUnitOfWork>();
            var repo = new Mock <IEmployerRepository>();

            repo.Setup(r => r.Update(It.IsNotNull <Employer>()))
            .Verifiable();

            uow.Setup(u => u.SaveChanges())
            .ReturnsAsync(1)
            .Verifiable();

            uow.Setup(u => u.EmployerRepository)
            .Returns(repo.Object)
            .Verifiable();

            var manager = new EmployerManager(uow.Object);
            //act
            var result = manager.Update(new Employer()).Result;

            //assert
            repo.Verify();
            uow.Verify();
            Assert.True(result.Succeeded);
        }
Example #3
0
        public void Get_succeeded_if_username_is_valid()
        {
            //arrange
            var uow     = new Mock <IUnitOfWork>();
            var repo    = new Mock <IUserRepository>();
            var admRepo = new Mock <IEmployerRepository>();

            repo.Setup(r => r.FindByUserName(It.IsNotNull <string>()))
            .ReturnsAsync(new User {
                UserId = Guid.NewGuid()
            })
            .Verifiable();

            admRepo.Setup(a => a.FindById(It.Is <Guid>(g => g != Guid.Empty)))
            .ReturnsAsync(new Employer())
            .Verifiable();

            uow.Setup(u => u.EmployerRepository)
            .Returns(admRepo.Object)
            .Verifiable();

            uow.Setup(u => u.UserRepository)
            .Returns(repo.Object)
            .Verifiable();

            var manager = new EmployerManager(uow.Object);
            //act
            var result = manager.Get("name").Result;

            //assert
            repo.Verify();
            admRepo.Verify();
            uow.Verify();
            Assert.NotNull(result);
        }
Example #4
0
        public Int32 ReadEmployer()
        {
            Int32           Result          = 0;
            EmployerManager EmployerManager = new EmployerManager();

            Result = EmployerManager.ReadEmployer();
            return(Result);
        }
Example #5
0
        public void DeleteEmployer_failed_if_name_is_null()
        {
            //arrange
            var uow     = Mock.Of <IUnitOfWork>();
            var manager = new EmployerManager(uow);
            //act
            var result = manager.Delete((String)null).Result;

            //assert
            Assert.False(result.Succeeded);
        }
Example #6
0
        public void Get_returns_null_if_username_is_not_valid()
        {
            //arrange
            var uow     = Mock.Of <IUnitOfWork>();
            var manager = new EmployerManager(uow);
            //act
            var result = manager.Get(null).Result;

            //assert
            Assert.Null(result);
        }
Example #7
0
        public void UpdateEmployer_failed_if_Employer_is_not_valid()
        {
            //arrange
            var uow     = Mock.Of <IUnitOfWork>();
            var manager = new EmployerManager(uow);
            //act
            var result = manager.Update(null).Result;

            //assert
            Assert.False(result.Succeeded);
        }
Example #8
0
        public void DeleteEmployer_failed_if_id_is_not_valid()
        {
            //arrange
            var uow     = Mock.Of <IUnitOfWork>();
            var manager = new EmployerManager(uow);
            //act
            var result = manager.Delete(Guid.Empty).Result;

            //assert
            Assert.False(result.Succeeded);
        }
Example #9
0
        public void DeleteEmployer_succeeded_if_name_is_valid()
        {
            //arrange
            var EmployerToDelete = new Employer {
                User = new User()
            };
            var Employers = new List <Employer> {
                EmployerToDelete
            };
            var uow     = new Mock <IUnitOfWork>();
            var repo    = new Mock <IEmployerRepository>();
            var usrRepo = new Mock <IUserRepository>();

            usrRepo.Setup(u => u.Remove(It.IsNotNull <User>()))
            .Callback <User>(a => Employers.Remove(EmployerToDelete))
            .Verifiable();

            usrRepo.Setup(u => u.FindByUserName(It.IsNotNull <string>()))
            .ReturnsAsync(new User {
                UserId = Guid.NewGuid()
            })
            .Verifiable();

            repo.Setup(r => r.FindById(It.Is <Guid>(g => g != Guid.Empty)))
            .ReturnsAsync(EmployerToDelete)
            .Verifiable();

            uow.Setup(u => u.SaveChanges())
            .ReturnsAsync(1)
            .Verifiable();

            uow.Setup(u => u.UserRepository)
            .Returns(usrRepo.Object)
            .Verifiable();

            uow.Setup(u => u.EmployerRepository)
            .Returns(repo.Object)
            .Verifiable();

            var manager = new EmployerManager(uow.Object);
            //act
            var result = manager.Delete("asdasd").Result;

            //assert
            usrRepo.Verify();
            repo.Verify();
            uow.Verify();
            Assert.True(result.Succeeded);
            Assert.Equal(0, Employers.Count);
        }
 public ActionResult Employers(EmployerSignUpView ESV)
 {
     if (ModelState.IsValid)
     {
         EmployerManager EM = new EmployerManager();
         if (!EM.IsLoginNameExist(ESV.Email))
         {
             EM.AddEmployerAccount(ESV);
             FormsAuthentication.SetAuthCookie(ESV.contactName, false);
             return(RedirectToAction("Welcome", "Home"));
         }
         else
         {
             ModelState.AddModelError("", "Login Name already taken.");
         }
     }
     return(View());
 }
Example #11
0
        public ActionResult CreateProject(CreateProjectBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.ModelState = ModelState;
            }
            else
            {
                var result = ProjectManager.Create(model);
                switch (result)
                {
                case ProjectManager.createprojectstatus.failed:
                    ViewBag.Failed = Fa.Error;
                    break;

                case ProjectManager.createprojectstatus.duplicate:
                    ViewBag.Duplicate = Fa.DuplicateExecuter;
                    break;

                default:
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.Employers = EmployerManager.List();
            var colleges = CollegeManager.List();

            ViewBag.College       = colleges;
            ViewBag.ResearchGroup = ResearchGroupManager.List();
            if (colleges.Count > 0)
            {
                var educationalgroup = EducationalGroupManager.FindByCollegeId(colleges.FirstOrDefault().Id);
                ViewBag.EducationalGroup = educationalgroup;
                ViewBag.Executer         = ExecuterManager.FindByCollegeId(colleges.FirstOrDefault().Id);
            }
            else
            {
                ViewBag.EducationalGroup = new List <EducationalGroupModel>();
                ViewBag.Executer         = new List <ExecuterModel>();
            }
            ViewBag.ResearchGroup = ResearchGroupManager.List();
            return(View(model));
        }
Example #12
0
        public ActionResult CreateProject()
        {
            ViewBag.Employers = EmployerManager.List();
            var colleges = CollegeManager.List();

            ViewBag.College       = colleges;
            ViewBag.ResearchGroup = ResearchGroupManager.List();
            if (colleges.Count > 0)
            {
                var educationalgroup = EducationalGroupManager.FindByCollegeId(colleges.FirstOrDefault().Id);
                ViewBag.EducationalGroup = educationalgroup;
                ViewBag.Executer         = ExecuterManager.FindByCollegeId(colleges.FirstOrDefault().Id);
            }
            else
            {
                ViewBag.EducationalGroup = new List <EducationalGroupModel>();
                ViewBag.Executer         = new List <ExecuterModel>();
            }
            ViewBag.ResearchGroup = ResearchGroupManager.List();
            return(View());
        }
Example #13
0
        public ActionResult EditProject(int id)
        {
            var project = ProjectManager.Find(id);

            if (project != null)
            {
                var set = new EditProjectBindingModel
                {
                    ProjectId               = project.ProjectId,
                    Title                   = project.Title,
                    EmployerId              = project.EmployerId,
                    CollegeId               = project.CollegeId,
                    EducationalGroupId      = project.EducationalGroupId,
                    ExecuterId              = project.ExecuterId,
                    ResearchGroupId         = project.ResearchGroupId,
                    Price                   = project.Price,
                    OverHeadPrice           = project.OverHeadPrice,
                    ReceivePrice            = project.ReceivePrice,
                    RemainPrice             = project.RemainPrice,
                    PaymentPrice            = project.PaymentPrice,
                    MainContractId          = project.MainContractId,
                    MainContractDateStr     = Utility.DateToString(project.MainContractDate),
                    InternalContractId      = project.MainContractId,
                    InternalContractDateStr = Utility.DateToString(project.InternalContractDate),
                    ProjectEndDateStr       = Utility.DateToString(project.ProjectEndDate),
                    PhasesNum               = project.PhasesNum,
                    ProjectStatus           = project.ProjectStatus,
                    ProjectType             = project.ProjectType,
                    Explain                 = project.Explain,
                };
                var colleges = CollegeManager.List();
                ViewBag.College          = colleges;
                ViewBag.EducationalGroup = EducationalGroupManager.FindByCollegeId(project.CollegeId);
                ViewBag.ResearchGroup    = ResearchGroupManager.List();
                ViewBag.Employers        = EmployerManager.List();
                ViewBag.Executer         = ExecuterManager.FindByCollegeId(project.CollegeId);
                return(View(set));
            }
            return(RedirectToAction("Index"));
        }
Example #14
0
        public void Get_succeeded_if_id_is_valid()
        {
            //arrange
            var uow  = new Mock <IUnitOfWork>();
            var repo = new Mock <IEmployerRepository>();

            repo.Setup(r => r.FindById(It.Is <Guid>(g => g != Guid.Empty)))
            .ReturnsAsync(new Employer())
            .Verifiable();

            uow.Setup(u => u.EmployerRepository)
            .Returns(repo.Object)
            .Verifiable();

            var manager = new EmployerManager(uow.Object);
            //act
            var result = manager.Get(Guid.NewGuid()).Result;

            //assert
            repo.Verify();
            uow.Verify();
            Assert.NotNull(result);
        }
Example #15
0
        public ActionResult ProjectInfo(int id)
        {
            var project = ProjectManager.Find(id);

            if (project != null)
            {
                var set = new ProjectViewModel
                {
                    Title                = project.Title,
                    ProjectId            = project.ProjectId,
                    Price                = project.Price,
                    OverHeadPrice        = project.OverHeadPrice,
                    ReceivePrice         = project.ReceivePrice,
                    RemainPrice          = project.RemainPrice,
                    PaymentPrice         = project.PaymentPrice,
                    MainContractId       = project.MainContractId,
                    MainContractDate     = Utility.DateToString(project.MainContractDate),
                    InternalContractId   = project.MainContractId,
                    InternalContractDate = Utility.DateToString(project.InternalContractDate),
                    ProjectEndDate       = Utility.DateToString(project.ProjectEndDate),
                    PhasesNum            = project.PhasesNum,
                    ProjectStatus        = project.ProjectStatus,
                    ProjectType          = project.ProjectType,
                    Explain              = project.Explain,
                    Id = project.Id,
                };
                set.Employer = EmployerManager.Find(project.EmployerId).Name;
                var executer = ExecuterManager.FindExecuter(project.ExecuterId);
                set.Executer         = executer.FirstName + " " + executer.LastName;
                set.College          = CollegeManager.Find(project.CollegeId).Name;
                set.EducationalGroup = EducationalGroupManager.Find(project.EducationalGroupId).Name;
                set.ResearchGroup    = ResearchGroupManager.Find(project.ResearchGroupId).Name;
                ViewBag.ProjectInfo  = set;
                return(View());
            }
            return(RedirectToAction("Error"));
        }
Example #16
0
 public Boolean insertEmployer(EmployerDto dto)
 {
     Employer obj = Employer.createEmployer(dto.EmployerId, dto.EmployerName);
     EmployerManager mgr = new EmployerManager();
     return mgr.insertEmployer(obj);
 }
Example #17
0
    public List<EmployerDto> selectAllEmployer()
    {
        EmployerManager mgr = new EmployerManager();
        List<Employer> employerList = mgr.selectAllEmployer();
        List<EmployerDto> dtoList = new List<EmployerDto>();

        foreach (Employer employer in employerList)
        {
            dtoList.Add(EmployerDto.createEmployerDTO(employer));
        }

        return dtoList;
    }
Example #18
0
 public EmployerDto selectEmployerById(System.Guid EmployerId)
 {
     EmployerManager mgr = new EmployerManager();
     Employer obj = new Employer();
     obj.EmployerId = EmployerId;
     obj = mgr.selectEmployerById(obj);
     if (obj != null)
     {
         return EmployerDto.createEmployerDTO(obj);
     }
     else
     {
         return null;
     }
 }
Example #19
0
 public EmployerController(DataBaseContext dbContext)
 {
     this._dbContext  = dbContext;
     _employerManager = new EmployerManager(dbContext);
 }
Example #20
0
 public Boolean insertEmployer(System.Guid EmployerId, String EmployerName)
 {
     Employer obj = Employer.createEmployer(EmployerId, EmployerName);
     EmployerManager mgr = new EmployerManager();
     return mgr.insertEmployer(obj);
 }