コード例 #1
0
 public void AddLine(Line line)
 {
     if (line != null)
     {
         using (PhoneCompanyContext context = new PhoneCompanyContext())
         {
             try
             {
                 //if(line.Client != null)
                 //{
                 //    line.ClientId = line.Client.Id;
                 //    line.Client = null;
                 //}
                 //if (line.Package != null)
                 //{
                 //    line.PackageId = line.Package.Id;
                 //    line.Package = null;
                 //}
                 context.Lines.Add(line);
                 //context.Entry(line.Client).State = System.Data.Entity.EntityState.Unchanged;
                 //context.Entry(line.Package).State = System.Data.Entity.EntityState.Unchanged;
                 context.Entry(line).State = System.Data.Entity.EntityState.Added;
                 context.SaveChanges();
             }
             catch (Exception x)
             {
                 Debug.Write(x.Message);
             }
         }
     }
 }
コード例 #2
0
 public void AddClient(Client client)
 {
     if (client != null)
     {
         using (PhoneCompanyContext context = new PhoneCompanyContext())
         {
             context.Entry(client.TypeId).State = System.Data.Entity.EntityState.Unchanged;
             context.Entry(client).State        = System.Data.Entity.EntityState.Added;
             context.Clients.Add(client);
             context.SaveChanges();
         }
     }
 }
コード例 #3
0
 public void SendCall(SMS sMS)
 {
     if (sMS != null)
     {
         using (PhoneCompanyContext context = new PhoneCompanyContext())
         {
             context.Entry(sMS.Line).State = System.Data.Entity.EntityState.Unchanged;
             //context.Entry(sMS.Line.Package).State = System.Data.Entity.EntityState.Unchanged;
             context.Entry(sMS).State = System.Data.Entity.EntityState.Added;
             context.SMSs.Add(sMS);
             context.SaveChanges();
         }
     }
 }
コード例 #4
0
 public void AddPackageDetails(PackageInclude packageInclude)
 {
     if (packageInclude != null)
     {
         using (PhoneCompanyContext context = new PhoneCompanyContext())
         {
             try
             {
                 context.Entry(packageInclude.Package).State = System.Data.Entity.EntityState.Unchanged;
                 context.Entry(packageInclude).State         = System.Data.Entity.EntityState.Added;
                 context.PackageIncludes.Add(packageInclude);
                 context.SaveChanges();
             }
             catch (Exception x)
             {
                 Debug.Write(x.Message);
             }
         }
     }
 }
コード例 #5
0
 public void SendCall(Call call)
 {
     if (call != null)
     {
         using (PhoneCompanyContext context = new PhoneCompanyContext())
         {
             try
             {
                 //context.Entry(call.Line).State = System.Data.Entity.EntityState.Unchanged;
                 //context.Entry(call.Line.Package).State = System.Data.Entity.EntityState.Unchanged;
                 context.Entry(call).State = System.Data.Entity.EntityState.Added;
                 context.Calls.Add(call);
                 context.SaveChanges();
             }
             catch (Exception x)
             {
                 Debug.Write(x.Message);
                 throw;
             }
         }
     }
 }