Esempio n. 1
0
        public JsonResult Delete(EducationModel model)
        {
            try
            {
                #region " [ Declaration ] "

                EducationService _service = new EducationService();

                #endregion

                #region " [ Main process ] "

                model.CreateBy   = UserID;
                model.DeleteBy   = UserID;
                model.DeleteDate = DateTime.Now;

                #endregion

                //Call to service
                return(this.Json(_service.Delete(model), JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException serviceEx)
            {
                throw serviceEx;
            }
            catch (DataAccessException accessEx)
            {
                throw accessEx;
            }
            catch (Exception ex)
            {
                throw new ControllerException(FILE_NAME, "Delete", UserID, ex);
            }
        }
        public void GetEducation_Pass()
        {
            using (ApplicationDbContext context = new ApplicationDbContext(Options))
            {
                EducationService educationService = new EducationService(context);
                UserService      userService      = new UserService(context);

                User user = new User
                {
                    FirstName = "Kyle",
                    LastName  = "Burgi"
                };

                userService.AddUser(user);

                Education edu = new Education
                {
                    CollegeName  = "Eastern Washington University",
                    FieldOfStudy = "Computer Science",
                    UserId       = user.Id
                };

                educationService.AddEducation(edu);
            }

            using (ApplicationDbContext context = new ApplicationDbContext(Options))
            {
                EducationService educationService = new EducationService(context);
                Education        fetchedEducation = educationService.GetEducation(1);

                Assert.AreEqual("Eastern Washington University", fetchedEducation.CollegeName);
                Assert.AreEqual(1, fetchedEducation.UserId);
            }
        }
Esempio n. 3
0
 public void SetUpMethod()
 {
     this._repositoryMock   = new Mock <SnilDBContext>();
     this._mapperMock       = new Mock <IMapper>();
     this._loggerMock       = new Mock <NLogAdapter <CookieManagerTests> >();
     this._educationService = new EducationService(this._loggerMock.Object, this._repositoryMock.Object, this._mapperMock.Object);
 }
Esempio n. 4
0
        public HttpResponseMessage DeleteEducation(EducationModel model)
        {
            IUnitOfWork          uWork            = new UnitOfWork();
            IEducationRepository education        = new EducationRepository(uWork);
            IEducationService    educationService = new EducationService(education);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var result = educationService.DeleteEducation(model);
                    if (result != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, result));
                    }
                    else
                    {
                        string message = "Not deleted successfully";
                        return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Esempio n. 5
0
        public HttpResponseMessage GetEducationModels(EducationModel model)
        {
            IUnitOfWork          uWork            = new UnitOfWork();
            IEducationRepository education        = new EducationRepository(uWork);
            IEducationService    educationService = new EducationService(education);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var educationList = educationService.GetAllEducationList(model);
                    if (educationList != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, educationList));
                    }
                    else
                    {
                        string message = "Error in getting Data";
                        return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message));
            }
        }
Esempio n. 6
0
        public void EditEducationShoudEditOneOrMorePropertiesInEducation()
        {
            var options   = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_Tests").Options;
            var dbContext = new ApplicationDbContext(options);
            var service   = new EducationService(dbContext);

            var model = new UpdateDeleteEducationViewModel
            {
                Title = "Edited"
            };

            var education = new Education
            {
                Title = "New"
            };

            dbContext.Educations.Add(education);
            dbContext.SaveChanges();

            var educationToEdit = dbContext.Educations.First();

            service.EditEducation(educationToEdit, model);

            Assert.Equal("Edited", educationToEdit.Title);
        }
Esempio n. 7
0
        public ActionResult Edit(string id)
        {
            try
            {
                #region " [ Declaration ] "

                EducationTypeService _typeService = new EducationTypeService();
                EducationService     _service     = new EducationService();

                ViewBag.id   = id;
                ViewBag.type = _typeService.GetAll(UserID);

                #endregion

                // Call to service
                EducationModel model = _service.GetItemByID(new EducationModel()
                {
                    ID = new Guid(id), CreateBy = UserID, Insert = false
                });

                return(View(model));
            }
            catch (ServiceException serviceEx)
            {
                throw serviceEx;
            }
            catch (DataAccessException accessEx)
            {
                throw accessEx;
            }
            catch (Exception ex)
            {
                throw new ControllerException(FILE_NAME, "Edit", UserID, ex);
            }
        }
Esempio n. 8
0
        public void UpdateEducationByIdProfile_InvalidEducationObject_ShouldBeThrownValidationException()
        {
            Mock <IUnitOfWork> uow     = new Mock <IUnitOfWork>();
            EducationService   service = new EducationService(uow.Object);

            service.Update(It.IsAny <int>(), null);
        }
Esempio n. 9
0
        public void InsertEducationByIdProfile_InvalidEducationObject_ShouldBeThrownValidationException()
        {
            Mock <IUnitOfWork> uow     = new Mock <IUnitOfWork>();
            EducationService   service = new EducationService(uow.Object);

            service.Insert(null);
        }
Esempio n. 10
0
        public void GetEducationByIdProfile_InvalidProfileId_ShouldBeThrownValidationException()
        {
            Mock <IUnitOfWork> uow     = new Mock <IUnitOfWork>();
            EducationService   service = new EducationService(uow.Object);

            uow.Setup(a => a.ProgrammerProfiles.Get(It.IsAny <string>())).Returns((ProgrammerProfile)null);
            service.GetEducationByProfileId(It.IsAny <string>());
        }
Esempio n. 11
0
        public void DeleteEducation_InvalidEducationId_ShouldBeThrownValidationException()
        {
            Mock <IUnitOfWork> uow     = new Mock <IUnitOfWork>();
            EducationService   service = new EducationService(uow.Object);

            uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns((Education)null);
            service.Delete(It.IsAny <int>());
        }
Esempio n. 12
0
        public void DeleteEducation_DeletedEducationWithCorrectId_ShouldBeDeleted()
        {
            Mock <IUnitOfWork> uow     = new Mock <IUnitOfWork>();
            EducationService   service = new EducationService(uow.Object);

            uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns(new Education());
            service.Delete(It.IsAny <int>());
            uow.Verify(x => x.Save());
        }
Esempio n. 13
0
        public void UpdateEducation_EducationExist_ShouldBeEditingSaved()
        {
            Mock <IUnitOfWork> uow     = new Mock <IUnitOfWork>();
            EducationService   service = new EducationService(uow.Object);

            uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns(new Education());
            service.Update(It.IsAny <int>(), new EducationDTO());
            uow.Verify(x => x.Save());
        }
Esempio n. 14
0
        public void InsertEducationByIdProfile_InvalidEducationId_ShouldBeThrownValidationException()
        {
            Mock <IUnitOfWork> uow     = new Mock <IUnitOfWork>();
            EducationService   service = new EducationService(uow.Object);

            uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns(new Education());
            service.Insert(new EducationDTO {
                Id = 1
            });
        }
Esempio n. 15
0
        public void UpdateEducationByIdProfile_EducationIdNotMatch_ShouldBeThrownValidationException()
        {
            Mock <IUnitOfWork> uow     = new Mock <IUnitOfWork>();
            EducationService   service = new EducationService(uow.Object);

            service.Update(1, new EducationDTO()
            {
                Id = 2, ProgrammerId = "1", CloseDate = new DateTime(2010, 11, 10), EntryDate = new DateTime(2009, 10, 10), Level = "high", NameInstitution = "KPI"
            });
        }
    public async Task GetEducations()
    {
        // Arrange
        var svc = new EducationService();

        // Act
        var result = await svc.GetEducations();

        // Assert
        Assert.Equal(2, result.Count);
    }
Esempio n. 17
0
        public void UpdateEducationByIdProfile_InvalidEducationId_ShouldBeThrownValidationException()
        {
            Mock <IUnitOfWork> uow     = new Mock <IUnitOfWork>();
            EducationService   service = new EducationService(uow.Object);

            uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns((Education)null);
            service.Update(2, new EducationDTO()
            {
                Id = 2, ProgrammerId = "1", CloseDate = new DateTime(2010, 11, 10), EntryDate = new DateTime(2009, 10, 10), Level = "high", NameInstitution = "KPI"
            });
        }
 public static IEducationService<Education> GetJobSeekerEducation()
 {
     IEducationService<SkillSmart.Dto.Education> serviceObj = null;
     switch (sectionHandler.ConnectionStringName)
     {
         case DataBaseType.SKILLSMART_MONGO_DB: serviceObj = new EducationService(DatabaseFactory.CreateMongoDatabase());
             break;
         default: serviceObj = new EducationService(DatabaseFactory.CreateMongoDatabase());
             break;
     }
     return serviceObj;
 }
Esempio n. 19
0
        public void InsertEducation_NewEducationAddingToDatabase_ShouldBeAddedNewEducation()
        {
            Mock <IUnitOfWork> uow     = new Mock <IUnitOfWork>();
            EducationService   service = new EducationService(uow.Object);

            uow.Setup(a => a.Educations.Get(It.IsAny <int>())).Returns((Education)null);
            service.Insert(new EducationDTO()
            {
                Id = 1, ProgrammerId = "1", CloseDate = new DateTime(2010, 11, 10), EntryDate = new DateTime(2009, 10, 10), Level = "high", NameInstitution = "KPI"
            });
            uow.Verify(x => x.Save());
        }
        public void UpdateEducation_Pass()
        {
            using (ApplicationDbContext context = new ApplicationDbContext(Options))
            {
                EducationService educationService = new EducationService(context);
                UserService      userService      = new UserService(context);

                User user = new User
                {
                    FirstName = "Kyle",
                    LastName  = "Burgi"
                };

                userService.AddUser(user);

                Education edu = new Education
                {
                    CollegeName  = "Eastern Washington University",
                    FieldOfStudy = "Computer Science",
                    UserId       = user.Id
                };

                educationService.AddEducation(edu);
            }

            using (ApplicationDbContext context = new ApplicationDbContext(Options))
            {
                EducationService educationService = new EducationService(context);
                UserService      userService      = new UserService(context);

                List <User>      users         = userService.GetBatchUsers();
                List <Education> userEdcuation = educationService.GetEducationForUser(users[0].Id);

                Assert.IsTrue(userEdcuation.Count > 0);

                userEdcuation[0].CollegeName = "Gonzaga University";
                educationService.UpdateEducation(userEdcuation[0]);
            }

            using (ApplicationDbContext context = new ApplicationDbContext(Options))
            {
                EducationService educationService = new EducationService(context);
                UserService      userService      = new UserService(context);

                List <User>      users         = userService.GetBatchUsers();
                List <Education> userEdcuation = educationService.GetEducationForUser(users[0].Id);

                Assert.AreEqual("Gonzaga University", userEdcuation[0].CollegeName);
                Assert.AreEqual("Computer Science", users[0].EducationHistory[0].FieldOfStudy);
            }
        }
Esempio n. 21
0
        public async Task GetAllGroupBySpecialityTest()
        {
            _repoWrapper.Setup(r => r.Education.GetAllAsync(null, null)).ReturnsAsync(new List <Education>().AsQueryable());

            var service = new EducationService(_repoWrapper.Object, _mapper.Object);

            _mapper.Setup(x => x.Map <Education, EducationDTO>(It.IsAny <Education>())).Returns(new EducationDTO());
            // Act
            var result = await service.GetAllGroupBySpecialityAsync();

            // Assert
            Assert.NotNull(result);
            Assert.IsAssignableFrom <IEnumerable <EducationDTO> >(result);
        }
Esempio n. 22
0
        public async Task GetByIdTest()
        {
            _repoWrapper.Setup(r => r.Education.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <Education, bool> > >(), null)).ReturnsAsync(new Education());

            var service = new EducationService(_repoWrapper.Object, _mapper.Object);

            _mapper.Setup(x => x.Map <Education, EducationDTO>(It.IsAny <Education>())).Returns(new EducationDTO());
            // Act
            var result = await service.GetByIdAsync(1);

            // Assert
            Assert.NotNull(result);
            Assert.IsType <EducationDTO>(result);
        }
        public static IEducationService <Education> GetJobSeekerEducation()
        {
            IEducationService <SkillSmart.Dto.Education> serviceObj = null;

            switch (sectionHandler.ConnectionStringName)
            {
            case DataBaseType.SKILLSMART_MONGO_DB: serviceObj = new EducationService(DatabaseFactory.CreateMongoDatabase());
                break;

            default: serviceObj = new EducationService(DatabaseFactory.CreateMongoDatabase());
                break;
            }
            return(serviceObj);
        }
Esempio n. 24
0
        public FormInputResultInterview()
        {
            InitializeComponent();

            _scoreService      = new ScoreService();
            _resultService     = new ResultsService();
            _positionService   = new PositionService();
            _departmentService = new DepartmentService();
            _educationService  = new EducationService();

            LoadDataGridLookUpEdit();
            LoadDataGridLookUpEditPositions();
            LoadDataGridLookUpEditDepartments();
            LoadDataGridLookUpEditEducations();
        }
Esempio n. 25
0
        public void IncrementViewsShouldIncreaseCounterOnViews()
        {
            var options   = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_Tests").Options;
            var dbContext = new ApplicationDbContext(options);
            var service   = new EducationService(dbContext);

            dbContext.Educations.Add(new Education());
            dbContext.SaveChanges();

            var education = dbContext.Educations.First();

            service.IncrementViews(education);
            service.IncrementViews(education);

            Assert.Equal(2, education.Views);
        }
Esempio n. 26
0
        public void GetEducationsShouldReturnAllEducations()
        {
            var options   = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_Videos").Options;
            var dbContext = new ApplicationDbContext(options);
            var service   = new EducationService(dbContext);

            dbContext.Educations.Add(new Education());
            dbContext.Educations.Add(new Education());
            dbContext.Educations.Add(new Education());
            dbContext.Educations.Add(new Education());
            dbContext.Educations.Add(new Education());
            dbContext.SaveChanges();

            var educations = service.GetEducations();

            Assert.Equal(5, educations.Length);
        }
Esempio n. 27
0
        public void DeleteEducationShouldDeleteAnEducationFromDatabase()
        {
            var options   = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_Tests").Options;
            var dbContext = new ApplicationDbContext(options);
            var service   = new EducationService(dbContext);

            dbContext.Educations.Add(new Education());
            dbContext.Educations.Add(new Education());
            dbContext.Educations.Add(new Education());
            dbContext.SaveChanges();

            var education = dbContext.Educations.First();

            service.DeleteEducation(education);

            Assert.Equal(2, dbContext.Educations.Count());
        }
Esempio n. 28
0
        public void GetEducationShouldReturnAnEducationById()
        {
            var options   = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_CreatingEducations").Options;
            var dbContext = new ApplicationDbContext(options);
            var service   = new EducationService(dbContext);

            var education = new Education
            {
                Title = "Test"
            };

            dbContext.Educations.Add(education);
            dbContext.SaveChanges();

            var returnedEducation = service.GetEducation(1);

            Assert.Equal(education.Title, returnedEducation.Title);
        }
Esempio n. 29
0
        public void GetEducationByIdProfile_GetEducationWithCorrectProfileId_ShouldBeRecieved()
        {
            Mock <IUnitOfWork> mock    = new Mock <IUnitOfWork>();
            IUnitOfWork        uow     = mock.Object;
            EducationService   service = new EducationService(uow);

            IEnumerable <Education> educations = new List <Education>
            {
                new Education()
                {
                    Id = 1, ProgrammerId = "1"
                },
                new Education()
                {
                    Id = 2, ProgrammerId = "1"
                },
                new Education()
                {
                    Id = 3, ProgrammerId = "1"
                }
            };
            var expected = new List <EducationDTO>
            {
                new EducationDTO()
                {
                    Id = 1, ProgrammerId = "1"
                },
                new EducationDTO()
                {
                    Id = 2, ProgrammerId = "1"
                },
                new EducationDTO()
                {
                    Id = 3, ProgrammerId = "1"
                }
            };

            mock.Setup(a => a.ProgrammerProfiles.Get(It.IsAny <string>())).Returns(new ProgrammerProfile());
            mock.Setup(a => a.Educations.GetAll()).Returns(educations);
            var actual = service.GetEducationByProfileId("1");

            CollectionAssert.AreEquivalent(actual.Select(x => x.Id).ToList(), expected.Select(x => x.Id).ToList());
            CollectionAssert.AreEquivalent(actual.Select(x => x.ProgrammerId).ToList(), expected.Select(x => x.ProgrammerId).ToList());
        }
Esempio n. 30
0
        public void CreateEducationShouldCreateEducation()
        {
            var options   = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_CreatingEducations").Options;
            var dbContext = new ApplicationDbContext(options);
            var service   = new EducationService(dbContext);

            var model = new EducationViewModel
            {
                Title                  = "Title",
                AdditionalContent      = "Something",
                AdditionalContentImage = "Something",
                Content                = "Something",
                DownloadLink           = "Something",
                ImageUrl               = "Something",
            };

            var education = service.CreateEducation(model);

            Assert.Equal(1, education);
        }
Esempio n. 31
0
        public JsonResult Index(CustomDataTableRequestHelper requestData)
        {
            try
            {
                #region " [ Declaration ] "

                EducationService _service = new EducationService();

                #endregion

                #region " [ Main processing ] "

                if (requestData.Parameter1 == null)
                {
                    requestData.Parameter1 = "";
                }
                #endregion

                //Call to service
                Dictionary <string, object> _return = _service.List(requestData, UserID);
                if ((ResponseStatusCodeHelper)_return[DatatableCommonSetting.Response.STATUS] == ResponseStatusCodeHelper.OK)
                {
                    DataTableResponse <EducationModel> itemResponse = _return[DatatableCommonSetting.Response.DATA] as DataTableResponse <EducationModel>;
                    return(this.Json(itemResponse, JsonRequestBehavior.AllowGet));
                }
                //
                return(this.Json(new DataTableResponse <EducationModel>(), JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException serviceEx)
            {
                throw serviceEx;
            }
            catch (DataAccessException accessEx)
            {
                throw accessEx;
            }
            catch (Exception ex)
            {
                throw new ControllerException(FILE_NAME, "Index", UserID, ex);
            }
        }