Example #1
0
        public async Task <int> SavePersonInfo(PersonalInfoDTO personalInfoDto, string entityId)
        {
            using (var cardtrendentities = new pdb_ccmsContext(_connectionString))
            {
                IssMessageDTO issMessage = new IssMessageDTO();
                var           parameters = new object[] { Common.Helpers.Common.GetIssueNo(), personalInfoDto.EntityId, personalInfoDto.Title, personalInfoDto.FirstName, personalInfoDto.LastName,
                              personalInfoDto.NewIcType, personalInfoDto.NewIc, personalInfoDto.OldIcType, personalInfoDto.OldIc, personalInfoDto.Gender,
                              personalInfoDto.DOB, NumberExtensions.ConvertDecimalToDb(personalInfoDto.IncomeBK), personalInfoDto.Occupation, personalInfoDto.DeptId, personalInfoDto.DrivingLic };
                var paramNameList = new[]
                {
                    "@IssNo",
                    "@EntityId",
                    "@Title",
                    "@FirstName",
                    "@LastName",
                    "@NewIcType",
                    "@NewIc",
                    "@OldIcType",
                    "@OldIc",
                    "@Gender",
                    "@DOB",
                    "@Income",
                    "@Occupation",
                    "@DeptId",
                    "@DrivingLic"
                };
                var paramCollection = BuildParameterListWithRrn(parameters, paramNameList);
                var result          = await cardtrendentities.Database.ExecuteSqlCommandAsync(BuildSqlCommandWithRrn("WebEntityMaint", paramCollection), paramCollection.ToArray());

                var resultCode = paramCollection.Where(x => x.ParameterName == "@RETURN_VALUE").FirstOrDefault().Value;
                return(Convert.ToInt32(resultCode));
            }
        }
Example #2
0
        public async Task <PersonalInfoDTO> SavePersonalInfoAsync(PersonalInfoDTO personalInfoDTO, long UserId)
        {
            var personalInfo = _mapper.Map <PersonalInfo>(personalInfoDTO);

            personalInfo.ApplicationUserId = UserId;

            var response = personalInfoDTO.Id == 0 ?
                           await _personalInfoRepository.AddAsync(personalInfo) :
                           await _personalInfoRepository.UpdateAsync(personalInfo);

            return(_mapper.Map <PersonalInfoDTO>(response));
        }
 public void Add(PersonalInfoDTO personalInfo)
 {
     using (var uow = new UnitOfWork(new DataContext()))
     {
         var obj = new PersonalInfo();
         obj.CreateTimeStamp            = DateTime.Now;
         obj.ContactNumber              = personalInfo.ContactNumber;
         obj.Address                    = personalInfo.Address;
         obj.Birthday                   = personalInfo.Birthday;
         obj.BrotherCount               = personalInfo.BrotherCount;
         obj.Citizenship                = personalInfo.Citizenship;
         obj.CivilStatus                = personalInfo.CivilStatus;
         obj.EstimatedSalary            = personalInfo.EstimatedSalary;
         obj.FatherOccupation           = personalInfo.FatherOccupation;
         obj.FathersName                = personalInfo.FathersName;
         obj.HasRelativesMedicalIllness = personalInfo.HasRelativesMedicalIllness;
         obj.LengthOfResidency          = personalInfo.LengthOfResidency;
         obj.MotherOccupation           = personalInfo.MotherOccupation;
         obj.MothersName                = personalInfo.MothersName;
         obj.Name                   = personalInfo.Name;
         obj.Position               = personalInfo.Position;
         obj.PresentOccupation      = personalInfo.PresentOccupation;
         obj.PrimaryCourse          = personalInfo.PrimaryCourse;
         obj.PrimaryInclusiveDate   = personalInfo.PrimaryInclusiveDate;
         obj.PrimarySchoolName      = personalInfo.PrimarySchoolName;
         obj.Religion               = personalInfo.Religion;
         obj.SecondaryCourse        = personalInfo.SecondaryCourse;
         obj.SecondaryInclusiveDate = personalInfo.SecondaryInclusiveDate;
         obj.SecondarySchoolName    = personalInfo.SecondarySchoolName;
         obj.Sex                     = personalInfo.Sex;
         obj.SisterCount             = personalInfo.SisterCount;
         obj.SpouseName              = personalInfo.SpouseName;
         obj.SpouseOccupation        = personalInfo.SpouseOccupation;
         obj.TertiaryCourse          = personalInfo.TertiaryCourse;
         obj.TertiaryInclusiveDate   = personalInfo.TertiaryInclusiveDate;
         obj.TertiarySchoolName      = personalInfo.TertiarySchoolName;
         obj.VocationalCourse        = personalInfo.VocationalCourse;
         obj.VocationalInclusiveDate = personalInfo.VocationalInclusiveDate;
         obj.VocationalSchoolName    = personalInfo.VocationalSchoolName;
         obj.WorkingLength           = personalInfo.WorkingLength;
         obj.IsResidence             = personalInfo.IsResidence;
         obj.IsWorker                = personalInfo.IsWorker;
         uow.PersonalInfos.Add(obj);
         uow.Complete();
         personalInfo.PersonalInfoID = obj.PersonalInfoID;
     }
 }
Example #4
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            personalInfo = await _context.PersonalInfo.FirstOrDefaultAsync(m => m.ID == id);

            if (personalInfo == null)
            {
                return(NotFound());
            }
            personalInfoDTO = PersonalInfoMapper.ConvertToDTO(personalInfo);

            return(Page());
        }
 public PersonalInfoDTO Get(int id)
 {
     using (var uow = new UnitOfWork(new DataContext()))
     {
         var obj          = uow.PersonalInfos.Get(id);
         var personalInfo = new PersonalInfoDTO();
         personalInfo.Age                        = Utils.CalculateAge(obj.Birthday);
         personalInfo.ContactNumber              = obj.ContactNumber;
         personalInfo.Address                    = obj.Address;
         personalInfo.Birthday                   = obj.Birthday;
         personalInfo.BrotherCount               = obj.BrotherCount;
         personalInfo.Citizenship                = obj.Citizenship;
         personalInfo.CivilStatus                = obj.CivilStatus;
         personalInfo.EstimatedSalary            = obj.EstimatedSalary;
         personalInfo.FatherOccupation           = obj.FatherOccupation;
         personalInfo.FathersName                = obj.FathersName;
         personalInfo.HasRelativesMedicalIllness = obj.HasRelativesMedicalIllness;
         personalInfo.LengthOfResidency          = obj.LengthOfResidency;
         personalInfo.MotherOccupation           = obj.MotherOccupation;
         personalInfo.MothersName                = obj.MothersName;
         personalInfo.Name                       = obj.Name;
         personalInfo.Position                   = obj.Position;
         personalInfo.PresentOccupation          = obj.PresentOccupation;
         personalInfo.PrimaryCourse              = obj.PrimaryCourse;
         personalInfo.PrimaryInclusiveDate       = obj.PrimaryInclusiveDate;
         personalInfo.PrimarySchoolName          = obj.PrimarySchoolName;
         personalInfo.Religion                   = obj.Religion;
         personalInfo.SecondaryCourse            = obj.SecondaryCourse;
         personalInfo.SecondaryInclusiveDate     = obj.SecondaryInclusiveDate;
         personalInfo.SecondarySchoolName        = obj.SecondarySchoolName;
         personalInfo.Sex                        = obj.Sex;
         personalInfo.SisterCount                = obj.SisterCount;
         personalInfo.SpouseName                 = obj.SpouseName;
         personalInfo.SpouseOccupation           = obj.SpouseOccupation;
         personalInfo.TertiaryCourse             = obj.TertiaryCourse;
         personalInfo.TertiaryInclusiveDate      = obj.TertiaryInclusiveDate;
         personalInfo.TertiarySchoolName         = obj.TertiarySchoolName;
         personalInfo.VocationalCourse           = obj.VocationalCourse;
         personalInfo.VocationalInclusiveDate    = obj.VocationalInclusiveDate;
         personalInfo.VocationalSchoolName       = obj.VocationalSchoolName;
         personalInfo.WorkingLength              = obj.WorkingLength;
         personalInfo.IsResidence                = obj.IsResidence;
         personalInfo.IsWorker                   = obj.IsWorker;
         return(personalInfo);
     }
 }
        public async Task WhenSave_ShouldReturnOKWithResponse()
        {
            //arange
            var mockContext = new Mock <HttpContext>(MockBehavior.Strict);

            mockContext.SetupGet(hc => hc.User).Returns(new ClaimsPrincipal());

            var _userManagerMock = GetMockUserManager();

            _userManagerMock.Setup(x => x.FindByEmailAsync(It.IsAny <string>()))
            .ReturnsAsync(new ApplicationUser {
                Id = 1L, Email = "test.gmail.com", UserName = "******"
            });

            var personalInfoDTO = new PersonalInfoDTO
            {
                Id        = 1, Age = 40,
                FirstName = "Mario",
                LastName  = "Luigi",
                FitnessExperienceInMonths = 22,
                Gender     = "Male",
                HeightInCm = 180,
                WeightInKg = 75
            };

            var _personalinfoServiceMock = new Mock <IPersonalInfoService>();

            _personalinfoServiceMock.Setup(o => o.SavePersonalInfoAsync(personalInfoDTO, 1L))
            .ReturnsAsync(personalInfoDTO);


            var cabinetController = new PersonalInfoController(
                _userManagerMock.Object,
                _personalinfoServiceMock.Object);

            cabinetController.ControllerContext = new ControllerContext()
            {
                HttpContext = mockContext.Object
            };

            //act
            var result = await cabinetController.Post(personalInfoDTO);

            var response = result as OkObjectResult;

            //assert
            mockContext.VerifyGet(u => u.User, Times.Once());
            _personalinfoServiceMock.Verify(pi => pi.SavePersonalInfoAsync(It.IsAny <PersonalInfoDTO>(), It.IsAny <long>()), Times.Once);

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Value);
            Assert.IsNotNull(response.Value as PersonalInfoDTO);
            Assert.IsTrue((response.Value as PersonalInfoDTO).Age == 40);
            Assert.IsTrue((response.Value as PersonalInfoDTO).FirstName == "Mario");
            Assert.IsTrue((response.Value as PersonalInfoDTO).LastName == "Luigi");
            Assert.IsTrue((response.Value as PersonalInfoDTO).Id == 1L);
            Assert.IsTrue((response.Value as PersonalInfoDTO).HeightInCm == 180);
            Assert.IsTrue((response.Value as PersonalInfoDTO).WeightInKg == 75);
            Assert.IsTrue((response.Value as PersonalInfoDTO).Gender == "Male");
            Assert.IsTrue((response.Value as PersonalInfoDTO).FitnessExperienceInMonths == 22);
        }