public async Task <ActionResult <PPerson> > PostPPerson(PPerson pPerson) { _context.PPerson.Add(pPerson); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPPerson", new { id = pPerson.Id }, pPerson)); }
public async Task <IActionResult> PutPPerson(int id, PPerson pPerson) { if (id != pPerson.Id) { return(BadRequest()); } _context.Entry(pPerson).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PPersonExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <PPerson> AddUser(PPerson pPerson) { await dataContext.PPerson.AddAsync(pPerson); await dataContext.SaveChangesAsync(); return(pPerson); }
public static void Main(string[] args) { PPerson p1 = new PPerson("NewYork"); PPerson p2 = new PPerson("London"); AttributeReader <PPerson> .Read(p1); AttributeReader <PPerson> .Read(p2); }
// Copy Through Serialization Example public static void CopySerialization() { var john = new PPerson(new[] { "John", "Smith" }, new AAddress("London Road", 123)); var jane = john.DeepCopy(); // Extension Binary Serialization jane.Names[0] = "Jane"; jane.Address.HouseNumber = 321; WriteLine(john); WriteLine(jane); WriteLine(); var jane2 = jane.DeepCopyXml(); // Extension XML Serialization jane2.Names[0] = "Jane2"; jane2.Address.HouseNumber = 4321; WriteLine(john); WriteLine(jane); WriteLine(jane2); }