コード例 #1
0
        /// <summary>
        /// Delete Identifier
        /// </summary>
        /// <param name="context"></param>
        /// <param name="personId"></param>
        public void DeleteIdentifier(TestProjectDbContext context, Guid personId)
        {
            Person person = context.Person.AsNoTracking().FirstOrDefault(x => x.Id == personId);

            if (person == null)
            {
                throw new ErrorException("Person Id is invalid");
            }
            var identifiers = context.Identifier.Where(x => x.PersonId == personId);

            foreach (var identifier in identifiers)
            {
                context.Entry(identifier).State = EntityState.Deleted;
            }
            context.Identifier.RemoveRange();
            context.SaveChanges();
        }
コード例 #2
0
 /// <summary>
 /// Create Identifier
 /// </summary>
 /// <param name="context"></param>
 /// <param name="model"></param>
 public void CreateIdentifier(TestProjectDbContext context, Identifier model)
 {
     context.Identifier.Add(model);
     context.Entry(model).State = EntityState.Added;
     context.SaveChanges();
 }
コード例 #3
0
 /// <summary>
 /// update person
 /// </summary>
 /// <param name="context"></param>
 /// <param name="person"></param>
 public void UpdatePerson(TestProjectDbContext context, Person person)
 {
     context.Entry(person).State = EntityState.Modified;
     context.SaveChanges();
 }
コード例 #4
0
 /// <summary>
 /// Create person
 /// </summary>
 /// <param name="context"></param>
 /// <param name="model"></param>
 public void CreatePerson(TestProjectDbContext context, Person model)
 {
     context.Person.Add(model);
     context.Entry(model).State = EntityState.Added;
     context.SaveChanges();
 }
コード例 #5
0
 /// <summary>
 /// Delete Person
 /// </summary>
 /// <param name="context"></param>
 /// <param name="person"></param>
 public void DeletePerson(TestProjectDbContext context, Person person)
 {
     person.Deleted = true;
     context.Entry(person).State = EntityState.Modified;
     context.SaveChanges();
 }