/// <summary> /// Inserts a personal entity into the database which gets <c>offerId</c> as foreign key for the personal entity it relates to. /// </summary> /// <param name="offerId">The unique id of the offer</param> /// <param name="personal">The personal from which the entity is created</param> /// <returns></returns> private async Task InsertAsync(int offerId, Personal personal) { var personEntity = new PersonalEntity().Build(personal); personEntity.offer_id = offerId; await personEntity.InsertAsync(_context); personal.id = personEntity.id; }
public Personal build(PersonalEntity p) { NullCheck.ThrowIfNull <PersonalEntity>(p); id = p.id; institution = p.institution; researchgroup = p.researchgroup; experience_rt_pcr = p.experience_rt_pcr; annotation = p.annotation; qualification = p.qualification; area = p.area; return(this); }
public async Task MarkPersonalAsDeletedAsync(string token, int personalId, string reason) { NullCheck.ThrowIfNull <string>(reason); if (reason.Trim().Length == 0) { throw new ArgumentException(FailureCodes.InvalidReason); } // Get personal from database var query = from o in _context.offer as IQueryable <OfferEntity> join p in _context.personal on o.id equals p.offer_id where token == o.token && p.id == personalId select new { p, o }; var foundPersonals = await query.ToListAsync(); if (foundPersonals.Count == 0) { throw new DataNotFoundException(FailureCodes.NotFoundPersonal); } PersonalEntity personalEntity = foundPersonals[0].p; OfferEntity offerEntity = foundPersonals[0].o; personalEntity.is_deleted = true; await personalEntity.UpdateAsync(_context); await new ChangeEntity() { change_type = ChangeEntityChangeType.DeleteResource, element_id = personalEntity.id, element_type = ChangeEntityElementType.Personal, element_category = personalEntity.qualification, element_name = null, diff_amount = 1, reason = reason, timestamp = DateTime.Now, region = offerEntity.region }.InsertAsync(_context); }
public async Task Delete(PersonalEntity entity) { entity.DeletedAt = DateTime.Now; db.Update(entity); await context.SaveChangesAsync(); }
public async Task Create(PersonalEntity entity) { var entry = db.Add(entity); await context.SaveChangesAsync(); }