/// <summary> /// Downloads the content from database and puts it into the object. /// </summary> /// <param name="cr">credentials needed to download the data</param> /// <returns></returns> private static UserIdentity FromDatabase(Credentials cr) { try { UserModel u = UserManipulator.GetUser(cr.ToLib()); return(new UserIdentity(cr, u.Fullname, u.Email)); } catch (Exception ex) { throw new ActionException("Unable to get user details for the given credentials.", ActionType.User, MemeType.Fuuuuu, ex); } }
public ActionResult AddToDatabase() { try { UserManipulator.Add(((UserIdentity)this).ToLib()); } catch (Exception ex) { throw new ActionException("Unable to create new user account.", ActionType.User, MemeType.AreYouFuckingKiddingMe, ex); } return(new ActionResult("New account creted.", "Your account was created successfully.", ActionType.User)); }
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); } }