Ejemplo n.º 1
0
        public void SavingMachineSavesNicsAndHostAddresses()
        {
            Machine  machine = new Machine();
            Database db      = new SQLiteDatabase($"./{nameof(SavingMachineSavesNicsAndHostAddresses)}", "CoreRegistryRepository");

            db.TryEnsureSchema <Nic>();
            ApplicationRegistrationRepository repo = new ApplicationRegistrationRepository()
            {
                Database = db
            };

            Nic.LoadAll(repo.Database).Delete(repo.Database);
            HostAddress.LoadAll(repo.Database).Delete(repo.Database);
            ApplicationRegistration.Data.Dao.Machine.LoadAll(repo.Database).Delete(repo.Database);

            machine = machine.Save(repo) as Machine;
            machine.NetworkInterfaces.Each(n => OutLine(n.PropertiesToString(), ConsoleColor.Cyan));
            machine.HostAddresses.Each(h => OutLine(h.PropertiesToString(), ConsoleColor.Blue));

            NicCollection         nics  = Nic.LoadAll(repo.Database);
            HostAddressCollection hosts = HostAddress.LoadAll(repo.Database);

            Machine machineAgain = machine.Save(repo) as Machine;

            Expect.AreEqual(machine.Id, machineAgain.Id, "Id didn't match");
            Expect.AreEqual(machine.Uuid, machineAgain.Uuid, "Uuid didn't match");
            Expect.AreEqual(machine.Cuid, machineAgain.Cuid, "Cuid didn't match");

            NicCollection         nicsAgain  = Nic.LoadAll(repo.Database);
            HostAddressCollection hostsAgain = HostAddress.LoadAll(repo.Database);

            Expect.AreEqual(nics.Count, nicsAgain.Count, "Nic count didn't match");
            Expect.AreEqual(hosts.Count, hostsAgain.Count, "Host address count didn't match");
        }
Ejemplo n.º 2
0
 public ActionResult Update(Bam.Net.CoreServices.ApplicationRegistration.Data.Dao.HostAddress dao)
 {
     try
     {
         dao.Save();
         return(Json(new { Success = true, Message = "", Dao = dao.ToJsonSafe() }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
Ejemplo n.º 3
0
 public ActionResult Delete(long id)
 {
     try
     {
         string msg = "";
         Bam.Net.CoreServices.ApplicationRegistration.Data.Dao.HostAddress dao = Bam.Net.CoreServices.ApplicationRegistration.Data.Dao.HostAddress.OneWhere(c => c.KeyColumn == id);
         if (dao != null)
         {
             dao.Delete();
         }
         else
         {
             msg = string.Format("The specified id ({0}) was not found in the table (HostAddress)", id);
         }
         return(Json(new { Success = true, Message = msg, Dao = "" }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
Ejemplo n.º 4
0
 public ActionResult Create(Bam.Net.CoreServices.ApplicationRegistration.Data.Dao.HostAddress dao)
 {
     return(Update(dao));
 }