public PersonPublication GetByID(int _personPublicationId) { PersonPublicationDAC _personPublicationComponent = new PersonPublicationDAC(); IDataReader reader = _personPublicationComponent.GetByIDPersonPublication(_personPublicationId); PersonPublication _personPublication = null; while (reader.Read()) { _personPublication = new PersonPublication(); if (reader["PersonPublicationId"] != DBNull.Value) { _personPublication.PersonPublicationId = Convert.ToInt32(reader["PersonPublicationId"]); } if (reader["PersonId"] != DBNull.Value) { _personPublication.PersonId = Convert.ToInt32(reader["PersonId"]); } if (reader["PublicationTitle"] != DBNull.Value) { _personPublication.PublicationTitle = Convert.ToString(reader["PublicationTitle"]); } if (reader["PublicationAbstract"] != DBNull.Value) { _personPublication.PublicationAbstract = Convert.ToString(reader["PublicationAbstract"]); } if (reader["PublicationAttachmentPath"] != DBNull.Value) { _personPublication.PublicationAttachmentPath = Convert.ToString(reader["PublicationAttachmentPath"]); } _personPublication.NewRecord = false; } reader.Close(); return(_personPublication); }
public bool Insert(PersonPublication personpublication) { int autonumber = 0; PersonPublicationDAC personpublicationComponent = new PersonPublicationDAC(); bool endedSuccessfuly = personpublicationComponent.InsertNewPersonPublication(ref autonumber, personpublication.PersonId, personpublication.PublicationTitle, personpublication.PublicationAbstract, personpublication.PublicationAttachmentPath); if (endedSuccessfuly) { personpublication.PersonPublicationId = autonumber; } return(endedSuccessfuly); }
public async Task <IHttpActionResult> PostUserPublication(ViewModels.PersonPublicationDto dto) { // return Ok(client); if (dto == null) { return(Exceptions.getNullException(ModelState)); } if (!ModelState.IsValid) { // return BadRequest(ModelState); return(Exceptions.getModelValidationException(ModelState)); } // var validate = unitOfWork.PersonMiscRepository.Validate(dto); // if (validate.Code != HttpStatusCode.OK) // return validate; PersonPublication entity = null; if (dto.Id == -1) { entity = new PersonPublication(); unitOfWork.PersonRepository.Insert(entity); } else { entity = await unitOfWork.PersonRepository.GetPublicationByID(dto.Id); } if (entity == null) { return(Exceptions.getNotFoundException()); } //ViewModels.Location.Fill(entity, dto); ViewModels.PersonPublicationDto.Fill(entity, dto); var saveResult = await unitOfWork.SaveAsync(); if (saveResult.Code != HttpStatusCode.OK) { return(saveResult); } dto.Id = entity.Id; return(Ok(dto)); }
public List <PersonPublication> GetAll() { PersonPublicationDAC _personPublicationComponent = new PersonPublicationDAC(); IDataReader reader = _personPublicationComponent.GetAllPersonPublication().CreateDataReader(); List <PersonPublication> _personPublicationList = new List <PersonPublication>(); while (reader.Read()) { if (_personPublicationList == null) { _personPublicationList = new List <PersonPublication>(); } PersonPublication _personPublication = new PersonPublication(); if (reader["PersonPublicationId"] != DBNull.Value) { _personPublication.PersonPublicationId = Convert.ToInt32(reader["PersonPublicationId"]); } if (reader["PersonId"] != DBNull.Value) { _personPublication.PersonId = Convert.ToInt32(reader["PersonId"]); } if (reader["PublicationTitle"] != DBNull.Value) { _personPublication.PublicationTitle = Convert.ToString(reader["PublicationTitle"]); } if (reader["PublicationAbstract"] != DBNull.Value) { _personPublication.PublicationAbstract = Convert.ToString(reader["PublicationAbstract"]); } if (reader["PublicationAttachmentPath"] != DBNull.Value) { _personPublication.PublicationAttachmentPath = Convert.ToString(reader["PublicationAttachmentPath"]); } _personPublication.NewRecord = false; _personPublicationList.Add(_personPublication); } reader.Close(); return(_personPublicationList); }
public bool Update(PersonPublication personpublication, int old_personPublicationId) { PersonPublicationDAC personpublicationComponent = new PersonPublicationDAC(); return(personpublicationComponent.UpdatePersonPublication(personpublication.PersonId, personpublication.PublicationTitle, personpublication.PublicationAbstract, personpublication.PublicationAttachmentPath, old_personPublicationId)); }
public async Task <CustomActionResult> SaveAccompolishments(ViewModels.AccomplishmentDto dto) { var publication = await this.context.PersonPublications.FirstOrDefaultAsync(q => q.PersonId == dto.Id); var patent = await this.context.PersonPatents.FirstOrDefaultAsync(q => q.PersonId == dto.Id); var project = await this.context.PersonProjects.FirstOrDefaultAsync(q => q.PersonId == dto.Id); var certification = await this.context.PersonCertifications.FirstOrDefaultAsync(q => q.PersonId == dto.Id); var award = await this.context.PersonAwards.FirstOrDefaultAsync(q => q.PersonId == dto.Id); if (string.IsNullOrEmpty(dto.Publication.Title) && publication != null) { this.context.PersonPublications.Remove(publication); } else { if (publication == null) { publication = new PersonPublication() { PersonId = dto.Id }; this.context.PersonPublications.Add(publication); } publication.Publisher = dto.Publication.Publisher; publication.Remark = dto.Publication.Remark; publication.Title = dto.Publication.Title; publication.Date = dto.Publication.Date; } if (string.IsNullOrEmpty(dto.Patent.Title) && patent != null) { this.context.PersonPatents.Remove(patent); } else { if (patent == null) { patent = new PersonPatent() { PersonId = dto.Id }; this.context.PersonPatents.Add(patent); } patent.Title = dto.Patent.Title; patent.Date = dto.Patent.Date; patent.Remark = dto.Patent.Remark; patent.Issuer = dto.Patent.Issuer; } if (string.IsNullOrEmpty(dto.Project.Title) && project != null) { this.context.PersonProjects.Remove(project); } else { if (project == null) { project = new PersonProject() { PersonId = dto.Id }; this.context.PersonProjects.Add(project); } project.Title = dto.Project.Title; project.Remark = dto.Project.Remark; project.Date = dto.Project.Date; } if (string.IsNullOrEmpty(dto.Certification.Title) && certification != null) { this.context.PersonCertifications.Remove(certification); } else { if (certification == null) { certification = new PersonCertification() { PersonId = dto.Id }; this.context.PersonCertifications.Add(certification); } certification.Remark = dto.Certification.Remark; certification.Title = dto.Certification.Title; certification.Authority = dto.Certification.Authority; } if (string.IsNullOrEmpty(dto.Award.Title) && award != null) { this.context.PersonAwards.Remove(award); } else { if (award == null) { award = new PersonAward() { PersonId = dto.Id }; this.context.PersonAwards.Add(award); } award.Date = dto.Award.Date; award.Issuer = dto.Award.Issuer; award.Remark = dto.Award.Remark; award.Title = dto.Award.Title; } return(new CustomActionResult(HttpStatusCode.OK, true)); }
public virtual void Delete(PersonPublication entity) { this.context.PersonPublications.Remove(entity); }