Exemple #1
0
        public bool AddActivity(CallEntity call)
        {
            try
            {
                using (var context = new CellularDbContext())
                {
                    context.Calls.Add(call);
                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception)
            { /**/ return(false); }
        }

        public bool AddActivity(SMSEntity sms)
        {
            try
            {
                using (var context = new CellularDbContext())
                {
                    context.SMSMessages.Add(sms);
                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception)
            { /**/ return(false); }
        }
Exemple #2
0
        public void AddingClientWithEmployyeId()
        {
            using (var context = new CellularDbContext())
            {
                var OdedEmp = new Employee
                {
                    FirstName = "Oded",
                    LastName  = "Bartov",
                    Id        = 8888,
                    Password  = "******",
                    Rank      = EmployeeRank.CustomerRepresentative
                };

                var ilanCli = new Client
                {
                    RegisteredBy      = OdedEmp.Id,
                    Id                = 4646,
                    FirstName         = "Ilan",
                    LastName          = "Rozenfeld",
                    ClientTypeId      = ClientTypeEnum.VIP,
                    Password          = "******",
                    RegisterationDate = DateTime.Now.AddDays(-600)
                };

                context.Employees.Add(OdedEmp);
                context.Clients.Add(ilanCli);

                context.SaveChanges();
            }
        }
Exemple #3
0
        public bool AddActivity(IEnumerable <CallEntity> calls)
        {
            try
            {
                using (var context = new CellularDbContext())
                {
                    context.Calls.AddRange(calls);
                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception)
            { /**/ return(false); }
        }

        public bool AddActivity(IEnumerable <SMSEntity> smss)
        {
            try
            {
                using (var context = new CellularDbContext())
                {
                    context.SMSMessages.AddRange(smss);
                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception)
            { /**/ return(false); }
        }
Exemple #4
0
 public void AddPackage(Package package)
 {
     using (var db = new CellularDbContext())
     {
         db.Packages.Add(package);
         db.SaveChanges();
     }
 }
Exemple #5
0
 public void AddLine(Line line)
 {
     using (var db = new CellularDbContext())
     {
         db.Lines.Add(line);
         db.SaveChanges();
     }
 }
Exemple #6
0
 public void AddCall(Call call)
 {
     using (var context = new CellularDbContext())
     {
         context.Calls.Add(call);
         context.SaveChanges();
     }
 }
Exemple #7
0
 public void AddClient(Client client)
 {
     using (var db = new CellularDbContext())
     {
         db.Clients.Add(client);
         db.SaveChanges();
     }
 }
Exemple #8
0
 public void AddSMS(SMS sms)
 {
     using (var context = new CellularDbContext())
     {
         context.SMSes.Add(sms);
         context.SaveChanges();
     }
 }
Exemple #9
0
 public void DeleteLine(string lineNumber)
 {
     using (var db = new CellularDbContext())
     {
         var lineRemoved = db.Lines.FirstOrDefault(l => l.PhoneNumber == lineNumber);
         db.Lines.Remove(lineRemoved);
         db.SaveChanges();
     }
 }
Exemple #10
0
 public void DeletePackage(int packageId)
 {
     using (var db = new CellularDbContext())
     {
         var packageRemoved = db.Packages.FirstOrDefault(p => p.Id == packageId);
         db.Packages.Remove(packageRemoved);
         db.SaveChanges();
     }
 }
Exemple #11
0
 public Package EditPackage(Package package)
 {
     using (var db = new CellularDbContext())
     {
         var packageEdited = db.Packages.FirstOrDefault(p => p.Id == package.Id);
         db.Entry(packageEdited).CurrentValues.SetValues(package);
         db.SaveChanges();
         return(packageEdited);
     }
 }
 public bool AddBill(IEnumerable <BillEntity> bills)
 {
     try
     {
         using (var db = new CellularDbContext())
         {
             db.Bills.AddRange(bills);
             db.SaveChanges();
             return(true);
         }
     }
     catch { /* write to log */ return(false); }
 }
 public bool AddBill(BillEntity bill)
 {
     try
     {
         using (var db = new CellularDbContext())
         {
             db.Bills.Add(bill);
             db.SaveChanges();
             return(true);
         }
     }
     catch { /* write to log */ return(false); }
 }
Exemple #14
0
 public Client EditClient(Client client)
 {
     using (var db = new CellularDbContext())
     {
         var clientEdited = db.Clients.FirstOrDefault(c => c.Id == client.Id);
         clientEdited.FirstName    = client.FirstName;
         clientEdited.LastName     = client.LastName;
         clientEdited.Password     = client.Password;
         clientEdited.ClientTypeId = client.ClientTypeId;
         db.SaveChanges();
         return(clientEdited);
     }
 }
Exemple #15
0
        public void AddingData()
        {
            using (var context = new CellularDbContext())
            {
                Employee olegEmp = new Employee
                {
                    Id        = 1234,
                    FirstName = "Oleg",
                    LastName  = "Firumianz",
                    Password  = "******",
                    Rank      = EmployeeRank.CustomerRepresentative
                },
                         ItamarEmp = new Employee
                {
                    Id        = 4444,
                    FirstName = "Itamar",
                    LastName  = "Daisy",
                    Password  = "******",
                    Rank      = EmployeeRank.Manager
                };

                Client nirCli = new Client
                {
                    ClientTypeId      = ClientTypeEnum.VIP,
                    Id                = 3133,
                    FirstName         = "Nir",
                    LastName          = "London",
                    Password          = "******",
                    Registrator       = olegEmp,
                    RegisterationDate = DateTime.Now.AddDays(-40)
                },
                       shahafCli = new Client
                {
                    Id                = 1111,
                    Registrator       = ItamarEmp,
                    FirstName         = "Shahaf",
                    LastName          = "Dahan",
                    ClientTypeId      = ClientTypeEnum.Business,
                    Password          = "******",
                    RegisterationDate = DateTime.Now.AddDays(-60)
                };

                Line nirLine1;

                //context.Clients

                context.SaveChanges();
            }
        }
Exemple #16
0
 public void AddingPackage()
 {
     using (var context = new CellularDbContext())
     {
         context.Packages.Add(new Package
         {
             IncludesMinuets = true,
             MaxMinuets      = 200,
             IncludesSMSes   = true,
             MaxSMSes        = 10,
             LineNumber      = "056352417"
         });
         context.SaveChanges();
     }
 }
Exemple #17
0
 public bool AddUser(CustomerEntity user)
 {
     try
     {
         using (var db = new CellularDbContext())
         {
             db.Users.Add(user);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         // write fatal error to logger
         return(false);
     }
 }
 public bool AddLine(LineEntity line, int customerId)
 {
     try
     {
         using (var context = new CellularDbContext())
         {
             var customer = (from c in context.Customers
                             where c.UserId == customerId
                             select c).FirstOrDefault();
             customer.Lines.Add(line);
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         // write to log fatal error;
         return(false);
     }
 }