Example #1
0
        public ActionResult Create([Bind(Include = "ID,Email,Username,FirstName,LastName,BirthDate,JoinDate,Logo")] Member member)
        {
            if (ModelState.IsValid)
            {
                db.Members.Add(member);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(member));
        }
Example #2
0
        public ActionResult Add(string RedirectURL, int ScienceClubID, string TaskStateID, string Name, string Description, DateTime EndDay, DateTime StartDay, string Member, int CategoryOfTask)
        {
            db = new ScienceBookContext();
            string[] mem          = Member.Split(' ');
            string   fname        = mem[0];
            string   lname        = mem[1];
            var      _member      = db.Members.Where(m => m.FirstName.Equals(fname) && m.LastName.Equals(lname)).FirstOrDefault();
            var      _taskState   = db.TaskStates.FirstOrDefault();
            var      _scienceClub = db.ScienceClubs.Find(ScienceClubID);
            var      _catOfTask   = _scienceClub.CategoriesOfTasks.Where(c => c.ID == CategoryOfTask).FirstOrDefault();

            Task task = new Task
            {
                Name           = Name,
                Description    = Description,
                EndDay         = EndDay,
                StartDay       = StartDay,
                CategoryOfTask = _catOfTask,
                ScienceClub    = _scienceClub,
                TaskState      = _taskState,
                Member         = _member
            };

            db.Tasks.Add(task);
            db.SaveChanges();

            return(Redirect(RedirectURL));
        }
Example #3
0
        public ActionResult Add(string RedirectURL, int ScienceClubID, string Name, DateTime DayOfStart, DateTime DayOfEnd, int CountOfChoices, string options)
        {
            db = new ScienceBookContext();
            Election election = new Election
            {
                Name              = Name,
                ScienceClub       = db.ScienceClubs.Find(ScienceClubID),
                DayOfStart        = DayOfStart,
                DayOfEnd          = DayOfEnd,
                CountOfChoices    = CountOfChoices,
                OptionsInElection = new List <OptionsInElection>()
            };

            var opts = options.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None).ToList();

            foreach (var item in opts)
            {
                if (item.Contains("@"))
                {
                    var tempItem        = item.Replace('@', ' ');
                    var stringsInOption = tempItem.Split(' ');
                    var user            = db.ScienceClubs.Where(sc => sc.ID == ScienceClubID)
                                          .FirstOrDefault()
                                          .Members.Where(m => m.FirstName.Equals(stringsInOption[1]) && m.LastName.Equals(stringsInOption[2]))
                                          .FirstOrDefault();
                    if (user == null)
                    {
                        election.OptionsInElection.Add(new OptionsInElection
                        {
                            Value = item.Remove(0, 1)
                        });
                    }
                    else
                    {
                        election.OptionsInElection.Add(new OptionsInElection
                        {
                            Value = "<a href='/Members/Details/" + user.ID + "'>" + user.FirstName + " " + user.LastName + "</a>"
                        });
                    }
                }
                else
                {
                    election.OptionsInElection.Add(new OptionsInElection
                    {
                        Value = item
                    });
                }
            }

            db.Elections.Add(election);
            db.SaveChanges();

            return(Redirect(RedirectURL));
        }
Example #4
0
        public ActionResult Add(int ScienceClubID, string Title, string Text, string LogoBase64)
        {
            db = new ScienceBookContext();

            Post post = new Post
            {
                Member         = db.Members.Where(m => m.Email.Equals(User.Identity.Name)).FirstOrDefault(),
                ScienceClub    = db.ScienceClubs.Find(ScienceClubID),
                PublicationDay = DateTime.Now,
                Title          = Title,
                Text           = Text,
                Img            = LogoBase64
            };

            db.Posts.Add(post);
            db.SaveChanges();
            return(Redirect("/ScienceClubs/Details/" + ScienceClubID));
        }
Example #5
0
        // POST: AddEvent
        public ActionResult AddEvt(int ScienceClubID, string Title, string Description, string Link, DateTime StartDay, DateTime EndDay, string LogoBase24)
        {
            var scienceClub = db.ScienceClubs.Find(ScienceClubID);

            scienceClub.Events.Add(new Event
            {
                Name           = Title,
                Description    = Description,
                Link           = Link,
                StartDay       = StartDay,
                EndDay         = EndDay,
                PublicationDay = DateTime.Now,
                Member         = db.Members.Where(m => m.Email.Equals(User.Identity.Name)).FirstOrDefault(),
                Img            = LogoBase24
            });
            db.SaveChanges();

            return(Redirect("/ScienceClubs/Details?id=" + ScienceClubID));
        }
Example #6
0
        public ActionResult AddVote(int ElectionID, string[] electionOption)
        {
            db = new ScienceBookContext();
            var election = db.Elections.Find(ElectionID);

            foreach (var item in election.OptionsInElection)
            {
                foreach (var opt in electionOption)
                {
                    if (item.Value.Equals(opt))
                    {
                        item.Votes.Add(new Vote
                        {
                            Member = db.Members.Where(m => m.Email.Equals(User.Identity.Name)).FirstOrDefault()
                        });
                    }
                }
            }
            db.SaveChanges();
            return(Redirect("/ScienceClubs/Details/" + election.ScienceClubID));
        }
        // GET: ScienceClubs/Join/5
        public ActionResult Join(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var member = db.Members.Where(m => m.Email.Equals(User.Identity.Name)).FirstOrDefault();

            db.ScienceClubs.Find(id).Members.Add(member);

            var scienceClub = db.ScienceClubs.Find(id);
            var role        = db.Roles.Where(r => r.Name.Equals("Członek") && r.ScienceClubID == scienceClub.ID).First();

            scienceClub.ScienceClub_Member_Roles.Add(new ScienceClub_Member_Role
            {
                Member    = member,
                Role      = role,
                DayOfJoin = DateTime.Now
            });
            db.SaveChanges();

            return(RedirectToAction("Details", "ScienceClubs", new { id = id }));
        }