예제 #1
0
        public static void AddDirectory(CredentialsLib c, MachineModel m, DirModel d)
        {
            GetDirList(m);
            int NoSuchNameYet = (from o in m.Directories where o.Name == d.Name select o).Count();

            if (NoSuchNameYet != 0)
            {
                // throw new Exception("directory with given name already exists");
                //no action needed
            }
            else
            {
                d.Owner = UserManipulator.LoginToId(c.Login);
                AddDir(d);
                m.Id = MachManipulator.MachineNameToId(m.Name);
                AddMachDir(m, d);
            }
        }
예제 #2
0
        public static void AddMachine(CredentialsLib c, MachineModel m)
        {
            if (MachineNameExists(m.Name))
            {
                throw new Exception("machine with given name already exists");
            }
            else
            {
                int     user_id = UserManipulator.LoginToId(c.Login);
                Machine m1      = Machine.CreateMachine(1, user_id, m.Name);
                m1.machine_description = m.Description;

                using (filesyncEntities context = new filesyncEntities())
                {
                    context.Machines.AddObject(m1);
                    context.SaveChanges();
                }
            }
        }
예제 #3
0
        public static void GetMachineList(UserModel user)
        {
            List <MachineModel> machinelist = new List <MachineModel>();

            user.Id = UserManipulator.LoginToId(user.Login);
            using (filesyncEntities context = new filesyncEntities())
            {
                List <Machine> ml = (from o in context.Machines
                                     where o.user_id == user.Id
                                     select o).ToList();
                foreach (Machine m in ml)
                {
                    MachineModel m1 = new MachineModel(m.machine_name, m.machine_description);
                    m1.Id   = m.machine_id;
                    m1.User = m.user_id;
                    machinelist.Add(m1);
                }
                user.Machines = machinelist;
            }
        }