public static User userFromVMUser(VMUser vmUser) { User user = new User() { FirstName = vmUser.FirstName, LastName = vmUser.LastName, Email = vmUser.Email, ContactInfoes = contactInfoListFromVMContactInfoList(vmUser.ContactInfos), Educations = educationListFromVMEducationList(vmUser.Education), Portfolios = portfolioListFromVMportfolioList(vmUser.Portfolios), Links = linkListFromVMLinkList(vmUser.Links), TotalViews = vmUser.TotalViews, ViewsSinceLastReport = vmUser.ViewsSinceLastReport, LastDailyReportSendTime = vmUser.LastDailyReportSendTime, Id = vmUser.UserId }; return user; }
public ActionResult Account(int id=-1) { if (RouteData.Values["id"] != null) { if (int.TryParse(RouteData.Values["id"].ToString(), out id)) { } } if (id == -1) { //string error1 = "To view a User's account, you must pass in a User Id."; //ViewBag.ErrorMessages = new string[] { error1 }; //return View("PageNotFound"); id = WebSecurity.CurrentUserId; } PortfolioUnleashed.User user = db.retrieveUser(id); if (user == null) { string error1 = "The User whose account you tried to view either does not exist or could not be found."; string error2 = "User Id: "+ id; ViewBag.ErrorMessages = new string[] { error1, error2 }; return View("PageNotFound"); } VMUser vmUser = new VMUser(user); if (Request.IsAuthenticated) { if (id != WebSecurity.CurrentUserId) { ViewBag.IsQuickReference = db.retrieveQuickReferences(WebSecurity.CurrentUserId).Any(q => q.QuickReferenceId == id); } } return View(vmUser); }