public ActionResult Portfolio(int id=-1)
 {
     if (RouteData.Values["id"] != null)
     {
         if (int.TryParse(RouteData.Values["id"].ToString(), out id)) { }
     }
     Portfolio p = new Portfolio();
     if (id != -1)
     {
         p = db.retrievePortfolio(id);
         if (p == null)
         {
             string error1 = "The Portfolio you tried to view either does not exist or could not be found.";
             string error2 = "Portfolio Id: " + id;
             TempData["ErrorMessages"] = new string[] { error1, error2 };
             return RedirectToAction("Http404", "Error");
         }
     }
     VMPortfolio portfolio = new VMPortfolio(p);
     return View(model: portfolio);
 }
Beispiel #2
0
        public VMUser(User user, List <Project> projectsUserHasContributedTo = null)
        {
            FirstName               = user.FirstName;
            LastName                = user.LastName;
            Email                   = user.Email;
            ContactInfos            = new List <VMContactInfo>();
            LastDailyReportSendTime = user.LastDailyReportSendTime;
            ViewsSinceLastReport    = user.ViewsSinceLastReport;
            TotalViews              = user.TotalViews;

            if (user.ContactInfoes != null && user.ContactInfoes.Count > 0)
            {
                foreach (ContactInfo c in user.ContactInfoes)
                {
                    ContactInfos.Add(new VMContactInfo(c));
                }
            }

            Education = new List <VMEducation>();
            if (user.Educations != null && user.Educations.Count > 0)
            {
                foreach (Education e in user.Educations)
                {
                    Education.Add(new VMEducation(e));
                }
            }

            Links = new List <VMLink>();
            if (user.Links != null && user.Links.Count > 0)
            {
                foreach (Link l in user.Links)
                {
                    Links.Add(new VMLink(l));
                }
            }

            ProjectCatalog = new List <VMProject>();
            if (projectsUserHasContributedTo != null && projectsUserHasContributedTo.Count > 0)
            {
                foreach (Project p in projectsUserHasContributedTo)
                {
                    ProjectCatalog.Add(new VMProject(p, user.Id));
                }
            }

            Portfolios = new List <VMPortfolio>();
            if (user.Portfolios != null && user.Portfolios.Count > 0)
            {
                foreach (Portfolio p in user.Portfolios)
                {
                    Portfolios.Add(new VMPortfolio(p));
                }
                if (user.Portfolios.Any(p => p.IsMainPortfolio))
                {
                    MainPortfolio = new VMPortfolio(user.Portfolios.Where(p => p.IsMainPortfolio).FirstOrDefault());
                }
            }

            DatabaseDAL data = new DatabaseDAL();

            QuickContacts = new List <VMQuickContact>();
            if (user.QuickReferences != null && user.QuickReferences.Count > 0)
            {
                foreach (QuickReference q in user.QuickReferences)
                {
                    QuickContacts.Add(new VMQuickContact(data.retrieveUser(q.QuickReferenceId)));
                }
            }
            UserId = user.Id;

            Notifications = new List <VMNotification>();
            if (user.Notifications != null && user.Notifications.Count > 0)
            {
                foreach (var n in user.Notifications)
                {
                    Notifications.Add(new VMNotification(n));
                }
            }
        }
        public VMUser(User user, List<Project> projectsUserHasContributedTo=null)
        {
            FirstName = user.FirstName;
            LastName = user.LastName;
            Email = user.Email;
            ContactInfos = new List<VMContactInfo>();
            LastDailyReportSendTime = user.LastDailyReportSendTime;
            ViewsSinceLastReport = user.ViewsSinceLastReport;
            TotalViews = user.TotalViews;

            if (user.ContactInfoes != null && user.ContactInfoes.Count > 0)
            {
                foreach (ContactInfo c in user.ContactInfoes)
                {
                    ContactInfos.Add(new VMContactInfo(c));
                }
            }

            Education = new List<VMEducation>();
            if (user.Educations != null && user.Educations.Count > 0)
            {
                foreach (Education e in user.Educations)
                {
                    Education.Add(new VMEducation(e));
                }
            }

            Links = new List<VMLink>();
            if (user.Links != null && user.Links.Count > 0)
            {
                foreach (Link l in user.Links)
                {
                    Links.Add(new VMLink(l));
                }
            }

            ProjectCatalog = new List<VMProject>();
            if (projectsUserHasContributedTo != null && projectsUserHasContributedTo.Count>0)
            {
                foreach (Project p in projectsUserHasContributedTo)
                {
                    ProjectCatalog.Add(new VMProject(p, user.Id));
                }
            }

            Portfolios = new List<VMPortfolio>();
            if (user.Portfolios != null && user.Portfolios.Count > 0)
            {
                foreach (Portfolio p in user.Portfolios)
                {
                    Portfolios.Add(new VMPortfolio(p));
                }
                if(user.Portfolios.Any(p=> p.IsMainPortfolio))
                {
                    MainPortfolio = new VMPortfolio(user.Portfolios.Where(p => p.IsMainPortfolio).FirstOrDefault());
                }
            }

            DatabaseDAL data = new DatabaseDAL();

            QuickContacts = new List<VMQuickContact>();
            if (user.QuickReferences != null && user.QuickReferences.Count > 0)
            {
                foreach(QuickReference q in user.QuickReferences)
                {
                    QuickContacts.Add(new VMQuickContact(data.retrieveUser(q.QuickReferenceId)));
                }
            }
            UserId = user.Id;

            Notifications = new List<VMNotification>();
            if (user.Notifications != null && user.Notifications.Count > 0)
            {
                foreach (var n in user.Notifications)
                {
                    Notifications.Add(new VMNotification(n));
                }
            }
        }