public async Task <IActionResult> PutPersonEducation([FromRoute] int id, [FromBody] PersonEducation personEducation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != personEducation.Id) { return(BadRequest()); } _context.Entry(personEducation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonEducationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <Result <AddPersonEducationalLevelResponse> > Handle(PersonEducationLevelCommand request, CancellationToken cancellationToken) { try { EducationLevelService educationLevelService = new EducationLevelService(_unitOfWork); List <PersonEducation> personEducations = await educationLevelService.GetCurrentPersonEducation(request.PersonId); PersonEducation personEducation = new PersonEducation(); if (personEducations.Count > 0) { personEducations[0].EducationLevel = request.EducationalLevel; personEducation = await educationLevelService.UpdatePersonEducation(personEducations[0]); } else { PersonEducation ped = new PersonEducation(); ped.PersonId = request.PersonId; ped.CreatedBy = request.UserId; ped.EducationLevel = request.EducationalLevel; ped.CreateDate = DateTime.Now; personEducation = await educationLevelService.AddPersonEducation(ped); } return(Result <AddPersonEducationalLevelResponse> .Valid(new AddPersonEducationalLevelResponse() { Message = "Success", EducationLevelId = personEducation.Id })); } catch (Exception e) { return(Result <AddPersonEducationalLevelResponse> .Invalid(e.Message)); } }
public ActionResult AddPersonEducation(AddEducationViewModel education) { try { var newEducation = new PersonEducation { PersonId = _appContext.LoginId, InstituteName = education.InstituteName, Country = education.Country, Title = education.Title, Degree = education.Degree, YearOfGraduation = education.YearOfGraduation, CreatedOn = DateTime.Now, CreatedBy = _appContext.LoginId, UpdatedBy = _appContext.LoginId, UpdatedOn = DateTime.Now, }; _personEducationRepository.Add(newEducation); return(new JsonCamelCaseResult(new { Success = true, newEducation.Id }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(new JsonCamelCaseResult(new { Success = false, Message = "Error while adding new language" }, JsonRequestBehavior.AllowGet)); } }
public PersonEducation GetCurrentPersonEducation(int personId) { using (UnitOfWork unitOfWork = new UnitOfWork(new RecordContext())) { PersonEducation patienteducation = unitOfWork.PersonEducationRepository.FindBy(x => x.PersonId == personId & x.DeleteFlag == false).OrderByDescending(x => x.Id).Take(1).FirstOrDefault(); unitOfWork.Dispose(); return(patienteducation); } }
public int AddPersonEducationLevel(PersonEducation pated) { using (UnitOfWork unitOfWork = new UnitOfWork(new RecordContext())) { unitOfWork.PersonEducationRepository.Add(pated); result = unitOfWork.Complete(); unitOfWork.Dispose(); return(result); } }
public int UpdatePersonEducation(PersonEducation pe) { using (UnitOfWork unitOfWork = new UnitOfWork(new RecordContext())) { unitOfWork.PersonEducationRepository.Update(pe); result = unitOfWork.Complete(); unitOfWork.Dispose(); return(result); } }
private void AssertPersonEducation(PersonEducation edu, UpsertPersonEducationCommand sut) { Assert.NotNull(edu); Assert.Equal(1, edu.EducationId); Assert.Equal(sut.Degree, edu.Degree.Name); Assert.Equal(sut.Field, edu.EducationField.Name); Assert.Equal(sut.FromDate, edu.FromDate); Assert.Equal(sut.ToDate, edu.ToDate); Assert.Equal(Defaults.PersonId, edu.PersonId); }
public async Task <IActionResult> PostPersonEducation([FromBody] PersonEducation personEducation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.PersonEducation.Add(personEducation); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPersonEducation", new { id = personEducation.Id }, personEducation)); }
public bool Insert(PersonEducation personeducation) { int autonumber = 0; PersonEducationDAC personeducationComponent = new PersonEducationDAC(); bool endedSuccessfuly = personeducationComponent.InsertNewPersonEducation(ref autonumber, personeducation.PersonId, personeducation.InstitutionName, personeducation.Degree, personeducation.StartDate, personeducation.GraduationDate, personeducation.FinalGrade); if (endedSuccessfuly) { personeducation.PersonEducationId = autonumber; } return(endedSuccessfuly); }
public int UpdatePersonEducationalLevel(int PersonId, int UserId, int EducationalLevel) { PersonEducation pm = new PersonEducation() { PersonId = PersonId, EducationLevel = EducationalLevel, CreatedBy = UserId }; _result = _mgr.UpdatePersonEducation(pm); return(_result); }
public async Task <PersonEducation> UpdatePersonEducation(PersonEducation pm) { try { _commonUnitOfWork.Repository <PersonEducation>().Update(pm); await _commonUnitOfWork.SaveAsync(); return(pm); } catch (Exception e) { throw e; } }
public async Task <Result <GetPersonDetailsResponse> > Handle(GetPersonDetailsCommand request, CancellationToken cancellationToken) { try { RegisterPersonService rs = new RegisterPersonService(_unitOfWork); int id = request.PersonId; if (request.PersonId > 0) { persondetail = await rs.GetPerson(id); personEducation = await rs.GetCurrentPersonEducation(id); personocc = await rs.GetCurrentOccupation(id); personmarital = await rs.GetFirstPatientMaritalStatus(id); personlocation = await rs.GetCurrentPersonLocation(id); personcontact = await rs.GetCurrentPersonContact(id); personemerg = await rs.GetCurrentPersonEmergency(id); pid = await rs.GetCurrentPersonIdentifier(id); pt = await rs.GetPatientByPersonId(id); } _unitOfWork.Dispose(); return(Result <GetPersonDetailsResponse> .Valid(new GetPersonDetailsResponse() { personDetail = persondetail, personEducation = personEducation, personOccupation = personocc, personMaritalStatus = personmarital, personLocation = personlocation, personContact = personcontact, PersonEmergencyView = personemerg, personIdentifier = pid, patient = pt })); } catch (Exception ex) { return(Result <GetPersonDetailsResponse> .Invalid(ex.Message)); } }
public async Task <PersonEducation> AddPersonEducation(PersonEducation personEducation) { try { await _commonUnitOfWork.Repository <PersonEducation>().AddAsync(personEducation); await _commonUnitOfWork.SaveAsync(); return(personEducation); } catch (Exception e) { throw e; } }
public List <PersonEducation> GetAll() { PersonEducationDAC _personEducationComponent = new PersonEducationDAC(); IDataReader reader = _personEducationComponent.GetAllPersonEducation().CreateDataReader(); List <PersonEducation> _personEducationList = new List <PersonEducation>(); while (reader.Read()) { if (_personEducationList == null) { _personEducationList = new List <PersonEducation>(); } PersonEducation _personEducation = new PersonEducation(); if (reader["PersonEducationId"] != DBNull.Value) { _personEducation.PersonEducationId = Convert.ToInt32(reader["PersonEducationId"]); } if (reader["PersonId"] != DBNull.Value) { _personEducation.PersonId = Convert.ToInt32(reader["PersonId"]); } if (reader["InstitutionName"] != DBNull.Value) { _personEducation.InstitutionName = Convert.ToString(reader["InstitutionName"]); } if (reader["Degree"] != DBNull.Value) { _personEducation.Degree = Convert.ToString(reader["Degree"]); } if (reader["StartDate"] != DBNull.Value) { _personEducation.StartDate = Convert.ToDateTime(reader["StartDate"]); } if (reader["GraduationDate"] != DBNull.Value) { _personEducation.GraduationDate = Convert.ToDateTime(reader["GraduationDate"]); } if (reader["FinalGrade"] != DBNull.Value) { _personEducation.FinalGrade = Convert.ToString(reader["FinalGrade"]); } _personEducation.NewRecord = false; _personEducationList.Add(_personEducation); } reader.Close(); return(_personEducationList); }
public async Task <Result <AddPersonEducationalLevelResponse> > Handle(PersonEducationLevelCommand request, CancellationToken cancellationToken) { try { RegisterPersonService rs = new RegisterPersonService(_unitOfWork); if (request.PersonId > 0) { PersonEducation pme = new PersonEducation(); pme = await rs.GetCurrentPersonEducation(request.PersonId); if (pme != null) { pme.EducationLevel = request.EducationalLevel; pme.CreatedBy = request.UserId; await rs.UpdatePersonEducation(pme); msg += "Person Educatin updated successfully"; } else { PersonEducation ped = new PersonEducation(); ped.PersonId = request.PersonId; ped.CreatedBy = request.UserId; ped.EducationLevel = request.EducationalLevel; ped.CreateDate = DateTime.Now; var peducation = await rs.AddPersonEducation(ped); if (peducation != null) { msg = "PersonEducationalLevel added successfully for personId" + request.PersonId; } } } return(Result <AddPersonEducationalLevelResponse> .Valid(new AddPersonEducationalLevelResponse() { Message = msg })); } catch (Exception e) { return(Result <AddPersonEducationalLevelResponse> .Invalid(e.Message)); } }
public PersonEducation GetByID(int _personEducationId) { PersonEducationDAC _personEducationComponent = new PersonEducationDAC(); IDataReader reader = _personEducationComponent.GetByIDPersonEducation(_personEducationId); PersonEducation _personEducation = null; while (reader.Read()) { _personEducation = new PersonEducation(); if (reader["PersonEducationId"] != DBNull.Value) { _personEducation.PersonEducationId = Convert.ToInt32(reader["PersonEducationId"]); } if (reader["PersonId"] != DBNull.Value) { _personEducation.PersonId = Convert.ToInt32(reader["PersonId"]); } if (reader["InstitutionName"] != DBNull.Value) { _personEducation.InstitutionName = Convert.ToString(reader["InstitutionName"]); } if (reader["Degree"] != DBNull.Value) { _personEducation.Degree = Convert.ToString(reader["Degree"]); } if (reader["StartDate"] != DBNull.Value) { _personEducation.StartDate = Convert.ToDateTime(reader["StartDate"]); } if (reader["GraduationDate"] != DBNull.Value) { _personEducation.GraduationDate = Convert.ToDateTime(reader["GraduationDate"]); } if (reader["FinalGrade"] != DBNull.Value) { _personEducation.FinalGrade = Convert.ToString(reader["FinalGrade"]); } _personEducation.NewRecord = false; } reader.Close(); return(_personEducation); }
public async Task <Result <AddPersonEducationalLevelResponse> > Handle(PersonEducationLevelCommand request, CancellationToken cancellationToken) { PersonEducation plast = new PersonEducation(); try { if (request.PersonId > 0) { PersonEducationManager pme = new PersonEducationManager(); plast = pme.GetCurrentPersonEducation(request.PersonId); if (plast != null) { res = await Task.Run(() => pme.UpdatePersonEducationalLevel(request.PersonId, request.UserId, request.EducationalLevel)); if (res > 0) { msg = "PersonEducationLevel updated successfully"; } } else { res = await Task.Run(() => pme.AddPersonEducationLevel(request.PersonId, request.UserId, request.EducationalLevel)); if (res > 0) { msg = "PersonEducationalLevel added successfully for personId" + request.PersonId; } } } return(Result <AddPersonEducationalLevelResponse> .Valid(new AddPersonEducationalLevelResponse() { Message = msg })); } catch (Exception e) { return(Result <AddPersonEducationalLevelResponse> .Invalid(e.Message)); } }
internal static async Task SeedEducation(this ILifetimeScope scope, int educationId = 1, int personId = Defaults.PersonId) { var db = scope.Resolve <AppDbContext>(); var toAdd = new PersonEducation() { EducationId = educationId, PersonId = personId, ModifiedDate = Defaults.Today, School = new School() { SchoolId = 1, Name = "School", ModifiedDate = Defaults.Today } }; db.PersonEducation.Add(toAdd); await db.SaveChangesAsync(); }
private bool AddNewManualViolationToCDS(ManualViolationDTO manualViolation) { try { if (manualViolation == null) { corruptedRowsCount++; return(true); } var oldManualViolation = GetManualViolationFromCDS(manualViolation.ViolationNumber); if (oldManualViolation != null) { duplicatedRowsCount++; return(true); } var activityReason = context.ActivityReasonDIMs.Where(x => x.Description == manualViolation.Reason.Trim()).FirstOrDefault(); var activityCategory = context.ActivityCategoryDIMs.Where(x => x.Description == "Manual Violation").FirstOrDefault(); var source = context.Sources.Where(x => x.SourceName == "ManualViolation").FirstOrDefault(); var itemRegistrationAuthority = context.ItemRegistrationAuthorityDIMs.Where(x => x.Description == ((manualViolation.PlateSource != null && manualViolation.PlateSource.Trim().Length > 0) ? manualViolation.PlateSource : "Undefined")).FirstOrDefault(); var itemRegistrationKind = context.ItemRegistrationPlateKindDIMs.Where(x => x.Description == ((manualViolation.PlateKind != null && manualViolation.PlateKind.Trim().Length > 0) ? manualViolation.PlateKind : "Undefined")).FirstOrDefault(); var itemRegistrationCategory = context.ItemRegistrationPlateCategoryDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var itemRegistrationCode = context.ItemRegistrationPlateCodeDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var itemCategory = context.ItemCategoryDIMs.Where(x => x.Description == (manualViolation.VehicleType.Trim().Length > 0 ? manualViolation.VehicleType : "Undefined")).FirstOrDefault(); var itemInvolvement = context.ItemInvolvementDIMs.Where(x => x.Description == "Manual Violation Vehicle").FirstOrDefault(); var personInvolvement = context.PersonInvolvementDIMs.Where(x => x.Description == "Manual Violation Vehicle").FirstOrDefault(); var locationInvolvement = context.LocationInvolvementDIMs.Where(x => x.Description == "Manual Violation Vehicle").FirstOrDefault(); var personCategory = context.PersonCategoryDIMs.Where(x => x.Description == (manualViolation.AgeClass.Trim().Length > 0 ? manualViolation.AgeClass : "Undefined")).FirstOrDefault(); var personGender = context.PersonGenderDIMs.Where(x => x.Description == (manualViolation.Gender.Trim().Length > 0 ? manualViolation.Gender : "Undefined")).FirstOrDefault(); var location = context.Locations.Where(x => x.LocationName == (manualViolation.StreetName.Trim().Length > 0 ? manualViolation.StreetName : "Undefined")).FirstOrDefault(); var educationCategory = context.EducationCategoryDIMs.Where(x => x.Description == (manualViolation.LevelOfEducation.Trim().Length > 0 ? manualViolation.LevelOfEducation : "Undefined")).FirstOrDefault(); var educationDegree = context.EducationDegreeDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var organization = context.Organizations.Where(x => x.Name == "Undefined").FirstOrDefault(); var educationStatus = context.EducationStatusDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var locationDatum = context.LocationDatumDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var locationCategory = context.LocationCategoryDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); var status = context.StatusDIMs.Where(x => x.Description == "Undefined").FirstOrDefault(); if (activityReason == null) { activityReason = new ActivityReasonDIM { Code = "MVR-" + manualViolation.ReasonCode.ToString(), Description = manualViolation.Reason }; activityReason = context.ActivityReasonDIMs.Add(activityReason); context.SaveChanges(); } if (activityCategory == null) { activityCategory = new ActivityCategoryDIM { Description = "Manual Violation", Code = "MANUALVIOLATION" }; activityCategory = context.ActivityCategoryDIMs.Add(activityCategory); context.SaveChanges(); } if (source == null) { source = new Source() { Description = "ManualViolation", SourceName = "ManualViolation", SourcePolicyId = 1, SourceCategoryId = 1 }; source = context.Sources.Add(source); context.SaveChanges(); } if (itemRegistrationAuthority == null) { itemRegistrationAuthority = new ItemRegistrationAuthorityDIM { Description = (manualViolation.PlateSource != null && manualViolation.PlateSource.Trim().Length > 0) ? manualViolation.PlateSource : "Undefined", Code = GetRandomNumber() }; itemRegistrationAuthority = context.ItemRegistrationAuthorityDIMs.Add(itemRegistrationAuthority); context.SaveChanges(); } if (itemRegistrationKind == null) { itemRegistrationKind = new ItemRegistrationPlateKindDIM { Description = (manualViolation.PlateKind != null && manualViolation.PlateKind.Trim().Length > 0) ? manualViolation.PlateKind : "Undefined", Code = GetRandomNumber() }; itemRegistrationKind = context.ItemRegistrationPlateKindDIMs.Add(itemRegistrationKind); context.SaveChanges(); } if (itemRegistrationCategory == null) { itemRegistrationCategory = new ItemRegistrationPlateCategoryDIM { Description = "Undefined", Code = GetRandomNumber() }; itemRegistrationCategory = context.ItemRegistrationPlateCategoryDIMs.Add(itemRegistrationCategory); context.SaveChanges(); } if (itemRegistrationCode == null) { itemRegistrationCode = new ItemRegistrationPlateCodeDIM { Description = "Undefined", Code = GetRandomNumber() }; itemRegistrationCode = context.ItemRegistrationPlateCodeDIMs.Add(itemRegistrationCode); context.SaveChanges(); } if (itemCategory == null) { itemCategory = new ItemCategoryDIM { Description = manualViolation.VehicleType.Trim().Length > 0 ? manualViolation.VehicleType : "Undefined", Code = GetRandomNumber() }; itemCategory = context.ItemCategoryDIMs.Add(itemCategory); context.SaveChanges(); } if (itemInvolvement == null) { itemInvolvement = new ItemInvolvementDIM { Description = "Manual Violation Vehicle", Code = GetRandomNumber() }; itemInvolvement = context.ItemInvolvementDIMs.Add(itemInvolvement); context.SaveChanges(); } if (personInvolvement == null) { personInvolvement = new PersonInvolvementDIM { Description = "Manual Violation Vehicle", Code = GetRandomNumber() }; personInvolvement = context.PersonInvolvementDIMs.Add(personInvolvement); context.SaveChanges(); } if (locationInvolvement == null) { locationInvolvement = new LocationInvolvementDIM { Description = "Manual Violation Vehicle", Code = GetRandomNumber() }; locationInvolvement = context.LocationInvolvementDIMs.Add(locationInvolvement); context.SaveChanges(); } var item = new Item { ItemCategoryId = itemCategory.ItemCategoryId, SourceId = source.SourceId, }; item = context.Items.Add(item); context.SaveChanges(); var itemReg = new ItemRegistration { ItemRegistrationAuthorityId = itemRegistrationAuthority.ItemRegistrationAuthorityId, ItemRegistrationPlateCategoryId = itemRegistrationCategory.ItemRegistrationPlateCategoryId, ItemRegistrationPlateCodeId = itemRegistrationCode.ItemRegistrationPlateCodeId, ItemRegistrationPlateKindId = itemRegistrationKind.ItemRegistrationPlateKindId, SourceId = source.SourceId, PlateIdentification = "Undefiend", ItemId = item.ItemId }; itemReg = context.ItemRegistrations.Add(itemReg); context.SaveChanges(); if (personCategory == null) { personCategory = new PersonCategoryDIM { Code = GetRandomNumber(), Description = manualViolation.AgeClass.Trim().Length > 0 ? manualViolation.AgeClass : "Undefined" }; personCategory = context.PersonCategoryDIMs.Add(personCategory); context.SaveChanges(); } if (personGender == null) { personGender = new PersonGenderDIM { Code = GetRandomNumber(), Description = (manualViolation.Gender.Trim().Length > 0 ? manualViolation.Gender : "Undefined") }; personGender = context.PersonGenderDIMs.Add(personGender); context.SaveChanges(); } if (educationCategory == null) { educationCategory = new EducationCategoryDIM { Code = GetRandomNumber(), Description = manualViolation.LevelOfEducation.Trim().Length > 0 ? manualViolation.LevelOfEducation : "Undefined" }; educationCategory = context.EducationCategoryDIMs.Add(educationCategory); context.SaveChanges(); } if (educationDegree == null) { educationDegree = new EducationDegreeDIM { Code = GetRandomNumber(), Description = "Undefined" }; educationDegree = context.EducationDegreeDIMs.Add(educationDegree); context.SaveChanges(); } if (educationStatus == null) { educationStatus = new EducationStatusDIM { Code = GetRandomNumber(), Description = "Undefined" }; educationStatus = context.EducationStatusDIMs.Add(educationStatus); context.SaveChanges(); } if (organization == null) { organization = new Organization { Name = "Undefined", Description = "Undefined", SourceId = source.SourceId }; organization = context.Organizations.Add(organization); context.SaveChanges(); } Person person = new Person { SourceId = source.SourceId, LastName = manualViolation.OwnerName, OriginalIdent = manualViolation.OwnerTCFNumber, PersonCategoryId = personCategory.PersonCategoryId, PersonGenderId = personGender.PersonGenderId, Age = manualViolation.Age }; person = context.People.Add(person); context.SaveChanges(); var personDriverLicense = new PersonDriverLicense { EffectiveDate = manualViolation.LicenseIssueDate, PersonDriverLicenseDescription = manualViolation.LicenseSource, PersonId = person.PersonId, SourceId = source.SourceId }; personDriverLicense = context.PersonDriverLicenses.Add(personDriverLicense); context.SaveChanges(); var levelOfEducation = new PersonEducation { PersonEducationDescription = manualViolation.LevelOfEducation.Trim().Length > 0 ? manualViolation.LevelOfEducation : "Undefined", PersonId = person.PersonId, SourceId = source.SourceId, EducationCategoryId = educationCategory.EducationCategoryId, EducationDegreeId = educationDegree.EducationDegreeId, EducationStatusId = educationStatus.EducationStatusId, EducationOrganizationId = organization.OrganizationId }; levelOfEducation = context.PersonEducations.Add(levelOfEducation); context.SaveChanges(); if (locationDatum == null) { locationDatum = new LocationDatumDIM { Code = GetRandomNumber(), Description = "Undefined" }; locationDatum = context.LocationDatumDIMs.Add(locationDatum); context.SaveChanges(); } if (locationCategory == null) { locationCategory = new LocationCategoryDIM { Code = GetRandomNumber(), Description = "Undefined" }; locationCategory = context.LocationCategoryDIMs.Add(locationCategory); context.SaveChanges(); } //GeoPoint var geoPoint = DbGeometry.FromText( "POINT(" + (manualViolation.Lon) + " " + (manualViolation.Lat) + ")", 4326); if (location == null) { location = new Location { Latitude = manualViolation.Lat, Longitude = manualViolation.Lon, OrgLat = manualViolation.Lat.ToString(), OrgLong = manualViolation.Lon.ToString(), GeoPoint = geoPoint, Address1 = (manualViolation.StreetName.Trim().Length > 0 ? manualViolation.StreetName : "Undefined"), LocationName = (manualViolation.StreetName.Trim().Length > 0 ? manualViolation.StreetName : "Undefined"), Description = (manualViolation.StreetName.Trim().Length > 0 ? manualViolation.StreetName : "Undefined"), SourceId = source.SourceId, locationDatumId = locationDatum.LocationDatumId, LocationCategoryId = locationCategory.LocationCategoryId }; location = context.Locations.Add(location); context.SaveChanges(); } if (status == null) { status = new StatusDIM { Code = GetRandomNumber(), Description = "Undefined" }; status = context.StatusDIMs.Add(status); context.SaveChanges(); } Activity activity = new Activity() { ActivityDate = manualViolation.ViolationDate, OriginalIdent = manualViolation.ViolationNumber, SourceId = source.SourceId, ActivityReasonId = activityReason.ActivityReasonId, ActivityCategoryId = activityCategory.ActivityCategoryId, StatusId = status.StatusId }; activity = context.Activities.Add(activity); context.SaveChanges(); var activityLocation = new ActivityLocation() { LocationId = location.LocationId, ActivityId = activity.ActivityId, CreateDateTimeStamp = DateTime.Now, ModifiedDateTimeStamp = DateTime.Now, ActivityLocationDescription = "Manual Violation Location", SourceId = source.SourceId, LocationInvolvementId = locationInvolvement.LocationInvolvementId }; context.ActivityLocations.Add(activityLocation); context.SaveChanges(); var activityItem = new ActivityItem { ItemId = item.ItemId, ActivityId = activity.ActivityId, CreateDateTimeStamp = DateTime.Now, ModifiedDateTimeStamp = DateTime.Now, ItemInvolvementId = itemInvolvement.ItemInvolvementId, SourceId = source.SourceId }; context.ActivityItems.Add(activityItem); context.SaveChanges(); var activityPerson = new ActivityPerson { PersonId = person.PersonId, ActivityId = activity.ActivityId, CreateDateTimeStamp = DateTime.Now, ModifiedDateTimeStamp = DateTime.Now, SourceId = source.SourceId, PersonInvolvementId = personInvolvement.PersonInvolvementId }; context.ActivityPersons.Add(activityPerson); context.SaveChanges(); insertedRowsCount++; return(true); } catch (DbEntityValidationException ex) { Utility.WriteLog(ex); corruptedRowsCount++; return(false); } catch (DbUpdateException ex) { Utility.WriteLog(ex); corruptedRowsCount++; return(false); } catch (EntityCommandCompilationException ex) { Utility.WriteLog(ex); corruptedRowsCount++; return(false); } catch (EntityCommandExecutionException ex) { Utility.WriteLog(ex); corruptedRowsCount++; return(false); } catch (Exception ex) { Utility.WriteLog(ex); corruptedRowsCount++; return(false); } }
public bool Update(PersonEducation personeducation, int old_personEducationId) { PersonEducationDAC personeducationComponent = new PersonEducationDAC(); return(personeducationComponent.UpdatePersonEducation(personeducation.PersonId, personeducation.InstitutionName, personeducation.Degree, personeducation.StartDate, personeducation.GraduationDate, personeducation.FinalGrade, old_personEducationId)); }
public async Task <PersonEducation> UpdatePersonEducation(int personId, string educationlevel, string educationOutcome, int userid) { try { List <PersonEducation> personEducations = await _commonUnitOfWork.Repository <PersonEducation>() .Get(x => x.PersonId == personId && x.DeleteFlag == false && x.EducationLevel == Convert.ToInt32(educationlevel)).ToListAsync(); int educationlev = Convert.ToInt32(educationlevel); int educationout = Convert.ToInt32(educationOutcome); if (personEducations.Count > 0) { if (!String.IsNullOrEmpty(educationlevel)) { personEducations[0].EducationLevel = educationlev; } if (!string.IsNullOrEmpty(educationOutcome) || Convert.ToInt32(educationOutcome.ToString()) > 0) { if (!String.IsNullOrWhiteSpace(personEducations[0].EducationOutcome.ToString())) { if (personEducations[0].EducationOutcome != educationout) { personEducations[0].DeleteFlag = true; _commonUnitOfWork.Repository <PersonEducation>().Update(personEducations[0]); await _commonUnitOfWork.SaveAsync(); PersonEducation pe = new PersonEducation(); pe.PersonId = personId; pe.EducationLevel = educationlev; pe.EducationOutcome = educationout; pe.CreatedBy = userid; pe.CreateDate = DateTime.Now; personeducate = await this.AddPersonEducation(pe); return(personeducate); } else { personEducations[0].EducationOutcome = educationout; _commonUnitOfWork.Repository <PersonEducation>().Update(personEducations[0]); await _commonUnitOfWork.SaveAsync(); personeducate = personEducations[0]; } } else { personEducations[0].EducationOutcome = educationout; _commonUnitOfWork.Repository <PersonEducation>().Update(personEducations[0]); await _commonUnitOfWork.SaveAsync(); personeducate = personEducations[0]; } } else { _commonUnitOfWork.Repository <PersonEducation>().Update(personEducations[0]); await _commonUnitOfWork.SaveAsync(); } } else { PersonEducation pe = new PersonEducation(); pe.PersonId = personId; pe.EducationLevel = educationlev; if (Convert.ToInt32(educationOutcome.ToString()) > 0) { pe.EducationOutcome = educationout; } pe.CreatedBy = userid; pe.CreateDate = DateTime.Now; personeducate = await this.AddPersonEducation(pe); } return(personeducate); } catch (Exception e) { throw e; } }
public static void Seed(InteractiveCvContext context) { // Look for any Person. if (context.Person.Any()) { return; // DB has been seeded } var person = new Person { Name = "Full Name", Birthday = DateTime.Parse("1986-03-14"), AboutMe = "About me text", Location = "City, Country", EmailAddress = "Emailaddress" }; context.Person.Add(person); context.SaveChanges(); var education = new PersonEducation { PersonID = 1, SchoolName = "School Name", Course = "Course Title", Description = "Course Description", Location = "City, Country", StartDate = DateTime.Parse("2010-09-01"), EndDate = DateTime.Parse("2013-6-30") }; context.PersonEducation.Add(education); context.SaveChanges(); var experience = new PersonExperience { PersonID = 1, CompanyName = "Company Name", Function = "Function Title", Location = "City, Country", StartDate = DateTime.Parse("2013-09-01"), EndDate = DateTime.Parse("2015-6-30"), WebsiteUrl = "www.company.be", Description = "Function Description" }; context.PersonExperience.Add(experience); context.SaveChanges(); var categories = new AbilityCategory[] { new AbilityCategory { Description = "Skills" }, new AbilityCategory { Description = "Tools" } }; foreach (AbilityCategory c in categories) { context.AbilityCategory.Add(c); } context.SaveChanges(); var abilities = new PersonAbility[] { new PersonAbility { PersonID = 1, AbilityCategoryID = 1, Description = "SQL", Score = 3 }, new PersonAbility { PersonID = 1, AbilityCategoryID = 1, Description = "C#", Score = 4 }, new PersonAbility { PersonID = 1, AbilityCategoryID = 1, Description = "HTML(5)", Score = 3 }, new PersonAbility { PersonID = 1, AbilityCategoryID = 1, Description = "CSS", Score = 3 }, new PersonAbility { PersonID = 1, AbilityCategoryID = 1, Description = "Java", Score = 3 }, new PersonAbility { PersonID = 1, AbilityCategoryID = 1, Description = "Bootstrap Framework", Score = 2 }, new PersonAbility { PersonID = 1, AbilityCategoryID = 2, Description = "Visual Studio", Score = 3 }, new PersonAbility { PersonID = 1, AbilityCategoryID = 2, Description = "GitHub", Score = 2 }, new PersonAbility { PersonID = 1, AbilityCategoryID = 2, Description = "Microsoft Office", Score = 3 }, new PersonAbility { PersonID = 1, AbilityCategoryID = 2, Description = "SQL Server", Score = 2 }, new PersonAbility { PersonID = 1, AbilityCategoryID = 2, Description = "Windows Powershell", Score = 2 } }; foreach (PersonAbility p in abilities) { context.PersonAbility.Add(p); } context.SaveChanges(); }