public IActionResult Create([FromBody] AppUserEducation newmodel)
        {
            if (ModelState.IsValid)
            {
                _context.AppUserEducation.Add(newmodel);
                _context.SaveChanges();

                return(CreatedAtRoute("GetAppUserEducation", new { id = newmodel.AppUserEducationID }, newmodel));
            }
            else
            {
                return(BadRequest());
            }
        }
        public IActionResult UpdateEntry([FromBody] AppUserEducation objupd)
        {
            var targetObject = _context.AppUserEducation.FirstOrDefault(t => t.AppUserEducationID == objupd.AppUserEducationID);

            if (targetObject == null)
            {
                return(NotFound());
            }

            _context.Entry(targetObject).CurrentValues.SetValues(objupd);
            ReturnData ret;

            ret = _context.SaveData();

            if (ret.Message == "Success")
            {
                return(Ok());
            }

            return(NotFound(ret));
        }
Example #3
0
        public void AppUserEducation()
        {
            IQueryable <AppUserEducation> AppUserEducationCollection = Enumerable.Empty <AppUserEducation>().AsQueryable();
            AppUserEducation ct = new AppUserEducation {
                AppUserEducationID = 1, CreatedBy = "Test AppUserEducation"
            };

            Mock <IAppUserEducationRepository> AppUserEducationService = new Mock <IAppUserEducationRepository>();

            object obj = new object();

            try
            {
                AppUserEducationService.Setup(x => x.GetAll()).Returns(AppUserEducationCollection);
                AppUserEducationService.Setup(x => x.Get(It.IsAny <int>())).Returns(ct);
                AppUserEducationService.Setup(x => x.Add(It.IsAny <AppUserEducation>())).Returns(ct);
                AppUserEducationService.Setup(x => x.Delete(It.IsAny <AppUserEducation>())).Verifiable();
                AppUserEducationService.Setup(x => x.Update(It.IsAny <AppUserEducation>(), It.IsAny <object>())).Returns(ct);

                var AppUserEducationObject = AppUserEducationService.Object;
                var p1 = AppUserEducationObject.GetAll();
                var p2 = AppUserEducationObject.Get(1);
                var p3 = AppUserEducationObject.Update(ct, obj);
                var p4 = AppUserEducationObject.Add(ct);
                AppUserEducationObject.Delete(ct);

                Assert.IsAssignableFrom <IQueryable <AppUserEducation> >(p1);
                Assert.IsAssignableFrom <AppUserEducation>(p2);
                Assert.Equal("Test AppUserEducation", p2.CreatedBy);
                Assert.Equal("Test AppUserEducation", p3.CreatedBy);

                AppUserEducationService.VerifyAll();

                AppUserEducationObject.Dispose();
            }
            finally
            {
                AppUserEducationService = null;
            }
        }
Example #4
0
        public void AppUserEducation()
        {
            ILogger <AppUserEducationController> _testlogger = null;

            using (var context = new AppDbContext(options, null))
            {
                var controller = new AppUserEducationController(context, _testlogger);

                // Get all
                var result = controller.Get();
                // Assert
                var okResult = Assert.IsAssignableFrom <IEnumerable <AppUserEducation> >(result);
                var pgcount  = okResult.ToList().Count;
                Assert.Equal(2, pgcount);
                // Get by ID
                var result1   = controller.Get(1);
                var okResult1 = Assert.IsAssignableFrom <AppUserEducation>(result1);
                //var result1_1 = result1.FirstOrDefault();
                Assert.Equal("user1", result1.CreatedBy);
                // test update
                var pg1 = new AppUserEducation {
                    AppUserEducationID = 1, EducationTypeID = 1, CreatedBy = "user1 upd"
                };
                controller.UpdateEntry(pg1);
                var result3 = controller.Get(1);
                //var result3_1 = result3.FirstOrDefault();
                Assert.NotEqual("user1", result3.CreatedBy);
                Assert.Equal("user1 upd", result3.CreatedBy);
                // test delete
                var result4 = controller.Get(2);
                //var result4_1 = result4.FirstOrDefault();
                Assert.Equal("user1", result4.CreatedBy);

                IActionResult result5    = controller.Delete(2);
                var           viewResult = Assert.IsType <Microsoft.AspNetCore.Mvc.OkResult>(result5);
                var           result6    = controller.Get(2);
                Assert.Null(result6);
            }
        }
Example #5
0
        public IActionResult Update([FromBody] AppUserEducation editentry)
        {
            var result = _repository.Update(editentry, editentry.AppUserEducationID);

            return(Helper.CheckResult(result));
        }
Example #6
0
        public IActionResult Create([FromBody] AppUserEducation newentry)
        {
            var result = _repository.Add(newentry);

            return(Helper.CheckResult(result));
        }
Example #7
0
        internal void PopulateData()
        {
            using (var context = new AppDbContext(options, null))
            {
                if (context.AppUserAbsence.Count() < 1)
                {
                    var p1 = new AppUserAbsence {
                        AppUserAbsenceID = 1, Notes = "absence type 1",
                    };
                    var p2 = new AppUserAbsence {
                        AppUserAbsenceID = 2, Notes = "absence type 2",
                    };
                    context.AppUserAbsence.Add(p1);
                    context.AppUserAbsence.Add(p2);

                    context.SaveChanges();
                }

                if (context.AppUserAddress.Count() < 1)
                {
                    var p1 = new AppUserAddress {
                        AppUserAddressID = 1, Address1 = "address type 1", CountryID = 1, AddressTypeID = 1
                    };
                    var p2 = new AppUserAddress {
                        AppUserAddressID = 2, Address1 = "address type 2", CountryID = 1, AddressTypeID = 1
                    };
                    context.AppUserAddress.Add(p1);
                    context.AppUserAddress.Add(p2);

                    var p3 = new Country {
                        CountryID = 1, CountryName = "test country"
                    };
                    context.Country.Add(p3);
                    var p4 = new AddressType {
                        AddressTypeID = 1, AddressTypeName = "test address type"
                    };
                    context.AddressType.Add(p4);

                    context.SaveChanges();
                }

                if (context.AppUserCertificate.Count() < 1)
                {
                    var p1 = new AppUserCertificate {
                        AppUserCertificateID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserCertificate {
                        AppUserCertificateID = 2, CreatedBy = "user1",
                    };
                    context.AppUserCertificate.Add(p1);
                    context.AppUserCertificate.Add(p2);

                    context.SaveChanges();
                }

                if (context.AppUserContact.Count() < 1)
                {
                    var p1 = new AppUserContact {
                        AppUserContactID = 1, ContactTypeID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserContact {
                        AppUserContactID = 2, ContactTypeID = 1, CreatedBy = "user1",
                    };
                    context.AppUserContact.Add(p1);
                    context.AppUserContact.Add(p2);

                    if (context.ContactType.Count() < 1)
                    {
                        var p3 = new ContactType {
                            ContactTypeID = 1, ContactTypeName = "user1"
                        };
                        context.ContactType.Add(p3);
                    }
                    context.SaveChanges();
                }

                if (context.AppUserContract.Count() < 1)
                {
                    var p1 = new AppUserContract {
                        AppUserContractID = 1, ContractTypeID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserContract {
                        AppUserContractID = 2, ContractTypeID = 1, CreatedBy = "user1",
                    };
                    context.AppUserContract.Add(p1);
                    context.AppUserContract.Add(p2);

                    if (context.ContractType.Count() < 1)
                    {
                        var p3 = new ContractType {
                            ContractTypeID = 1, ContractTypeName = "contract 1"
                        };
                        context.ContractType.Add(p3);
                    }

                    context.SaveChanges();
                }

                if (context.AppUserCountry.Count() < 1)
                {
                    var p1 = new AppUserCountry {
                        AppUserCountryID = 1, CountryID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserCountry {
                        AppUserCountryID = 2, CountryID = 1, CreatedBy = "user1",
                    };
                    context.AppUserCountry.Add(p1);
                    context.AppUserCountry.Add(p2);

                    if (context.Country.Count() < 1)
                    {
                        var p3 = new Country {
                            CountryID = 1, CountryName = "country 1"
                        };
                        context.Country.Add(p3);
                    }

                    context.SaveChanges();
                }

                if (context.AppUserEducation.Count() < 1)
                {
                    var p1 = new AppUserEducation {
                        AppUserEducationID = 1, EducationTypeID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserEducation {
                        AppUserEducationID = 2, EducationTypeID = 1, CreatedBy = "user1",
                    };
                    context.AppUserEducation.Add(p1);
                    context.AppUserEducation.Add(p2);

                    if (context.EducationType.Count() < 1)
                    {
                        var p3 = new EducationType {
                            EducationTypeID = 1, EducationName = "education type 1"
                        };
                        context.EducationType.Add(p3);
                    }

                    context.SaveChanges();
                }

                if (context.AppUserEmploymentRecord.Count() < 1)
                {
                    var p1 = new AppUserEmploymentRecord {
                        AppUserEmploymentRecordID = 1, ContractTypeID = 1, DepartureTypeID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserEmploymentRecord {
                        AppUserEmploymentRecordID = 2, ContractTypeID = 1, DepartureTypeID = 1, CreatedBy = "user1",
                    };
                    context.AppUserEmploymentRecord.Add(p1);
                    context.AppUserEmploymentRecord.Add(p2);

                    if (context.ContractType.Count() < 1)
                    {
                        var p3 = new ContractType {
                            ContractTypeID = 1, ContractTypeName = "contract type 1"
                        };
                        context.ContractType.Add(p3);
                    }
                    if (context.DepartureType.Count() < 1)
                    {
                        var p3 = new DepartureType {
                            DepartureTypeID = 1, DepartureTypeName = "departure type 1"
                        };
                        context.DepartureType.Add(p3);
                    }

                    context.SaveChanges();
                }

                if (context.AppUserFunction.Count() < 1)
                {
                    var p1 = new AppUserFunction {
                        AppUserFunctionID = 1, FunctionTypeID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserFunction {
                        AppUserFunctionID = 2, FunctionTypeID = 1, CreatedBy = "user1",
                    };
                    context.AppUserFunction.Add(p1);
                    context.AppUserFunction.Add(p2);

                    if (context.FunctionType.Count() < 1)
                    {
                        var p3 = new FunctionType {
                            FunctionTypeID = 1, FunctionTypeName = "function type 1"
                        };
                        context.FunctionType.Add(p3);
                    }

                    context.SaveChanges();
                }

                if (context.AppUserInRole.Count() < 1)
                {
                    var p1 = new AppUserInRole {
                        AppUserInRoleID = 1, RoleTypeID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserInRole {
                        AppUserInRoleID = 2, RoleTypeID = 1, CreatedBy = "user1",
                    };
                    context.AppUserInRole.Add(p1);
                    context.AppUserInRole.Add(p2);

                    if (context.RoleType.Count() < 1)
                    {
                        var p3 = new RoleType {
                            RoleTypeID = 1, RoleTypeName = "role type 1"
                        };
                        context.RoleType.Add(p3);
                    }

                    context.SaveChanges();
                }

                if (context.AppUserLanguage.Count() < 1)
                {
                    var p1 = new AppUserLanguage {
                        AppUserLanguageID = 1, LanguageTypeID = 1, ProficiencyTypeID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserLanguage {
                        AppUserLanguageID = 2, LanguageTypeID = 1, ProficiencyTypeID = 1, CreatedBy = "user1",
                    };
                    context.AppUserLanguage.Add(p1);
                    context.AppUserLanguage.Add(p2);

                    if (context.LanguageType.Count() < 1)
                    {
                        var p3 = new LanguageType {
                            LanguageTypeID = 1, LanguageTypeName = "language type 1"
                        };
                        context.LanguageType.Add(p3);
                    }
                    if (context.ProficiencyType.Count() < 1)
                    {
                        var p3 = new ProficiencyType {
                            ProficiencyTypeID = 1, ProficiencyTypeName = "proficiency type 1"
                        };
                        context.ProficiencyType.Add(p3);
                    }
                    context.SaveChanges();
                }

                if (context.AppUserNote.Count() < 1)
                {
                    var p1 = new AppUserNote {
                        AppUserNoteID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserNote {
                        AppUserNoteID = 2, CreatedBy = "user1",
                    };
                    context.AppUserNote.Add(p1);
                    context.AppUserNote.Add(p2);

                    context.SaveChanges();
                }

                if (context.AppUserResearchTeam.Count() < 1)
                {
                    var p1 = new AppUserResearchTeam {
                        AppUserResearchTeamID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserResearchTeam {
                        AppUserResearchTeamID = 2, CreatedBy = "user1",
                    };
                    context.AppUserResearchTeam.Add(p1);
                    context.AppUserResearchTeam.Add(p2);

                    context.SaveChanges();
                }

                if (context.AppUserTeamAssignment.Count() < 1)
                {
                    var p1 = new AppUserTeamAssignment {
                        AppUserTeamAssignmentID = 1, TeamID = 1, AssignmentTypeID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserTeamAssignment {
                        AppUserTeamAssignmentID = 2, TeamID = 1, AssignmentTypeID = 1, CreatedBy = "user1",
                    };
                    context.AppUserTeamAssignment.Add(p1);
                    context.AppUserTeamAssignment.Add(p2);

                    if (context.Team.Count() < 1)
                    {
                        var p3 = new Team {
                            TeamID = 1, TeamName = "team 1"
                        };
                        context.Team.Add(p3);
                    }

                    if (context.AssignmentType.Count() < 1)
                    {
                        var p4 = new AssignmentType {
                            AssignmentTypeID = 1, AssignmentTypeName = "assignment type 1"
                        };
                        context.AssignmentType.Add(p4);
                    }

                    context.SaveChanges();
                }

                if (context.AppUserTeam.Count() < 1)
                {
                    var p1 = new AppUserTeam {
                        AppUserTeamID = 1, TeamID = 1, CreatedBy = "user1",
                    };
                    var p2 = new AppUserTeam {
                        AppUserTeamID = 2, TeamID = 1, CreatedBy = "user1",
                    };
                    context.AppUserTeam.Add(p1);
                    context.AppUserTeam.Add(p2);

                    if (context.Team.Count() < 1)
                    {
                        var p3 = new Team {
                            TeamID = 1, TeamName = "team 1"
                        };
                        context.Team.Add(p3);
                    }

                    context.SaveChanges();
                }
            }
        }