Exemple #1
0
 public Client LoginClient(string clientId, string contactNumber)
 {
     using (var db = new CellDbContext())
     {
         try
         {
             ClientDb client = db.Clients.Include("Lines").Include("ClientType").ToList().Where(c => c.ClientId == clientId)
                               .Where(c => c.Lines.Select(L => L.Number == contactNumber).FirstOrDefault()).FirstOrDefault();
             return(client.ToDTO());
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.Message);
             return(null);
         }
     }
 }
Exemple #2
0
 public Client AddClient(Client client)
 {
     using (var db = new CellDbContext())
     {
         try
         {
             ClientDb newClient = client.FromDTO();
             db.Clients.Add(newClient);
             db.Entry(newClient).State = System.Data.Entity.EntityState.Added;
             db.SaveChanges();
             return(newClient.ToDTO());
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.Message);
             return(null);
         }
     }
 }