Beispiel #1
0
        public ActionResult ScienceClubPosts(int scienceClubID)
        {
            var sc    = db.ScienceClubs.Find(scienceClubID);
            var posts = sc.Posts.OrderBy(p => p.PublicationDay).ToList();

            if (sc.Logo != null)
            {
                ViewBag.Logo = Imager.ByteArrayToStringImage(sc.Logo);
            }
            else if (!sc.LogoS.Equals(""))
            {
                ViewBag.Logo = sc.LogoS;
            }
            else
            {
                ViewBag.Logo = $"https://avatars.dicebear.com/api/jdenticon/{sc.Name}.svg";
            }

            if (posts.Count <= 5)
            {
                ViewBag.Posts = posts;
            }
            else
            {
                ViewBag.Posts = new List <Post>();
                for (int i = 0; i < 5; i++)
                {
                    ViewBag.Posts.Add(posts[i]);
                }
            }
            return(PartialView("_ScienceClubPosts"));
        }
Beispiel #2
0
        public ActionResult GetScienceClubMembers(int id)
        {
            var scienceClub = db.ScienceClubs.Find(id);
            var members     = scienceClub.Members;
            var logos       = new List <string>();
            var roles       = new List <string>();

            foreach (var item in members)
            {
                logos.Add(Imager.ByteArrayToStringImage(item.Logo));
                roles.Add(db.ScienceClubs_Members_Roles
                          .Where(smr => smr.MemberID == item.ID && smr.Role.ScienceClubID == id)
                          .FirstOrDefault()
                          .Role.Name);
            }
            ViewBag.Roles   = roles;
            ViewBag.Logos   = logos;
            ViewBag.Members = members;

            return(PartialView("_ScienceClubMembers"));
        }
Beispiel #3
0
        public ActionResult ShowAll(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var scienceClub = db.ScienceClubs.Find(id);

            if (scienceClub.Logo != null)
            {
                ViewBag.Logo = Imager.ByteArrayToStringImage(scienceClub.Logo);
            }
            else if (!scienceClub.LogoS.Equals(""))
            {
                ViewBag.Logo = scienceClub.LogoS;
            }
            else
            {
                ViewBag.Logo = $"https://avatars.dicebear.com/api/jdenticon/{scienceClub.Name}.svg";
            }

            return(View(scienceClub));
        }
Beispiel #4
0
        public ActionResult GetUserScienceClubs()
        {
            var scienceClubs = db.Members.Where(m => m.Email.Equals(User.Identity.Name)).FirstOrDefault().ScienceClubs;
            var images       = new List <string>();

            foreach (var item in scienceClubs)
            {
                if (item.Logo != null)
                {
                    images.Add(Imager.ByteArrayToStringImage(item.Logo));
                }
                else if (!item.LogoS.Equals(""))
                {
                    images.Add(item.LogoS);
                }
                else
                {
                    images.Add($"https://avatars.dicebear.com/api/jdenticon/{item.Name}.svg");
                }
            }
            ViewBag.ScienceClubs = scienceClubs;
            ViewBag.Images       = images;
            return(PartialView("_UserScienceClubs"));
        }
        // GET: ScienceClubs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ScienceClub scienceClub = db.ScienceClubs.Find(id);

            if (scienceClub == null)
            {
                return(HttpNotFound());
            }
            if (scienceClub.Members.Contains(db.Members.Where(m => m.Email.Equals(User.Identity.Name)).FirstOrDefault()))
            {
                ViewBag.IsJoined = true;
            }
            else
            {
                ViewBag.IsJoined = false;
            }

            if (scienceClub.Logo != null)
            {
                ViewBag.Logo = Imager.ByteArrayToStringImage(scienceClub.Logo);
            }
            else if (!scienceClub.LogoS.Equals(""))
            {
                ViewBag.Logo = scienceClub.LogoS;
            }
            else
            {
                ViewBag.Logo = $"https://avatars.dicebear.com/api/jdenticon/{scienceClub.Name}.svg";
            }

            ScienceClubViewModel view = new ScienceClubViewModel();

            view.ScienceClub = scienceClub;
            var tasks = db.Tasks.Where(t => t.ScienceClubID == scienceClub.ID).ToList();
            var temp  = new List <Task>();

            foreach (var item in tasks)
            {
                if (item.EndDay >= DateTime.Now)
                {
                    temp.Add(item);
                }
            }
            tasks      = temp;
            tasks      = tasks.OrderBy(t => t.StartDay).ToList();
            view.Tasks = tasks;

            var elections = db.Elections.Where(e => e.ScienceClubID == scienceClub.ID && e.DayOfEnd >= DateTime.Now).ToList();

            view.Elections = elections;

            view.Event = db.Events.Where(e => e.ScienceClubID == scienceClub.ID).OrderBy(e => e.StartDay).FirstOrDefault();

            ViewBag.IsScienceClubAdmin = scienceClub.ScienceClub_Member_Roles.Any(smr => smr.Member.Email.Equals(User.Identity.Name) && !smr.Role.Name.Equals("Członek"));

            return(View(view));
        }