Beispiel #1
0
 public static Client getClient(Guid Id)
 {
     try
     {
         using (var ctx = new ApiDBContext())
         {
             return(ctx.Clients.FirstOrDefault(c => c.Id.Equals(Id)));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #2
0
 public static List <Client> GetClients()
 {
     try
     {
         using (var ctx = new ApiDBContext())
         {
             return(ctx.Clients.ToList());
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #3
0
 public static Client getClientByEmail(string email)
 {
     try
     {
         using (var ctx = new ApiDBContext())
         {
             return(ctx.Clients.FirstOrDefault(c => c.Email.Equals(email)));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #4
0
 public static void SaveClient(Client cl)
 {
     try
     {
         using (var ctx = new ApiDBContext())
         {
             ctx.Clients.Add(cl);
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #5
0
 public static void DisableClient(Client cl)
 {
     try
     {
         using (var ctx = new ApiDBContext())
         {
             var originalClient = ctx.Clients.Single(c => c.Id.Equals(cl.Id));
             originalClient.IsActive = false;
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #6
0
        public static void UpdateClient(Client cl)
        {
            try
            {
                using (var ctx = new ApiDBContext())
                {
                    var originalClient = ctx.Clients.Single(c => c.Id.Equals(cl.Id));

                    originalClient.FirstName = cl.FirstName;
                    originalClient.LastName  = cl.LastName;
                    originalClient.Born      = cl.Born;
                    originalClient.Address   = cl.Address;
                    originalClient.Phone     = cl.Phone;
                    originalClient.City      = cl.City;
                    originalClient.Country   = ctx.Country.FirstOrDefault(c => c.Id.Equals(cl.Country.Id));

                    ctx.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }