public async Task <Clients> Read(string name) { try { EntityLayer.Persons.Persons p = await _context.Persons.Where(p => p.Name == name).FirstOrDefaultAsync(); Clients cls = await _context.Clients.Where(cls => cls.Person.Name == name).FirstOrDefaultAsync(); return(cls); } catch (Exception) { return(null); } }
public async Task <Employees> Read(string name) { try { EntityLayer.Persons.Persons p = await context.Persons.Where(p => p.Name == name).FirstOrDefaultAsync(); Employees emps = await context.Employees.Where(emp => emp.Person.Name == name).FirstOrDefaultAsync(); return(emps); } catch (Exception) { return(null); } }
public async Task <Employees> Read(int id) { try { EntityLayer.Persons.Persons p = await context.Persons.Where(p => p.Id == id).FirstOrDefaultAsync(); Employees emps = await context.Employees.Where(emp => emp.PersonId == id).FirstOrDefaultAsync(); emps.Person = p; return(emps); } catch (Exception) { return(null); } }
public async Task <Credits> GetCredit(int id) { try { Credits credits = await _context.Credits.FirstOrDefaultAsync(c => c.Id == id); EntityLayer.Persons.Persons persons = await _context.Persons.FirstOrDefaultAsync(p => p.Id == credits.Id); credits.Client = persons; return(credits); } catch (Exception) { throw; } }
public async Task <ActionResult <Clients> > Delete(int id) { try { EntityLayer.Persons.Persons p = _context.Persons.Where(p => p.Id == id).FirstOrDefault(); Clients cls = _context.Clients.Where(cls => cls.PersonId == id).FirstOrDefault(); _context.Persons.Remove(p); _context.Clients.Remove(cls); if (await _context.SaveChangesAsync() > 0) { return(cls); } return(null); } catch (Exception) { return(null); } }
public async Task <ActionResult <Employees> > DeleteEmployee(int id) { try { EntityLayer.Persons.Persons p = context.Persons.Where(p => p.Id == id).FirstOrDefault(); Employees emp = context.Employees.OfType <Employees>().Where(emp => emp.PersonId == id).FirstOrDefault(); context.Employees.Remove(emp); context.Persons.Remove(p); if (await context.SaveChangesAsync() > 0) { return(emp); } return(null); } catch (Exception) { return(null); } }