Exemplo n.º 1
0
        public ActionResult UpdateInDatabase(Credentials cr, MachineIdentity newMid)
        {
            try {
                if (cr == null)
                {
                    throw new ArgumentNullException("cr", "user credentials must be provided");
                }

                MachManipulator.ChangeMachineDetails(cr.ToLib(), newMid.ToLib(), this.ToLib());
            } catch (Exception ex) {
                throw new ActionException("Error while updating machine details.",
                                          ActionType.Machine, MemeType.Fuuuuu, ex);
            }

            return(new ActionResult("Machine updated.",
                                    "Current machine details were saved in the database.", ActionType.Machine));
        }
Exemplo n.º 2
0
        public ActionResult AddToDatabase(Credentials cr)
        {
            try {
                if (cr == null)
                {
                    throw new ArgumentNullException("cr", "user credentials must be provided");
                }

                MachManipulator.AddMachine(cr.ToLib(), this.ToLib());
            } catch (Exception ex) {
                throw new ActionException("Failed to create a new machine.", ActionType.Machine,
                                          MemeType.Fuuuuu, ex);
            }

            return(new ActionResult("Machine created.",
                                    "Your new machine was added to the database.", ActionType.Machine));
        }
Exemplo n.º 3
0
 private static UserContents FromDatabase(Credentials cr)
 {
     try {
         UserModel u = UserManipulator.GetUser(cr.ToLib());
         MachManipulator.GetMachineList(u);
         List <MachineContents> machines = null;
         if (u.Machines.Count > 0)
         {
             machines = new List <MachineContents>();
             foreach (MachineModel m in u.Machines)
             {
                 machines.Add(new MachineContents(m));
             }
         }
         return(new UserContents(new UserIdentity(u), machines));
     } catch (Exception ex) {
         throw new ActionException("Unable to get list of machines for the user "
                                   + "with the given credentials.", ActionType.User, MemeType.Fuuuuu, ex);
     }
 }