예제 #1
0
        public ActionResult CreateEvent(CreateEventModel createEventObj)
        {
            Console.WriteLine("SetEvent triggered!");


            if (createEventObj.eventID == "NULL" || createEventObj.eventID == "null" || createEventObj.eventID == "Null")
            {
                return(RedirectToAction("Managment", "Home"));
            }



            EventModel eventObj = new EventModel();

            eventObj.eventID   = createEventObj.eventID;
            eventObj.startdate = createEventObj.startdate;
            eventObj.gender    = createEventObj.gender;
            eventObj.startdate = createEventObj.startdate;
            eventObj.eventtype = createEventObj.eventtype;

            Console.WriteLine(eventObj.eventID);
            Console.WriteLine(eventObj.startdate);
            Console.WriteLine(eventObj.gender);

            SqliteDataAccess.SaveEvent(eventObj);


            EventJudgeModel eventJudgeObj1 = new EventJudgeModel();
            EventJudgeModel eventJudgeObj2 = new EventJudgeModel();
            EventJudgeModel eventJudgeObj3 = new EventJudgeModel();

            eventJudgeObj1.eventID = createEventObj.eventID;
            eventJudgeObj1.judgeID = createEventObj.judge1ID;

            eventJudgeObj2.eventID = createEventObj.eventID;
            eventJudgeObj2.judgeID = createEventObj.judge2ID;

            eventJudgeObj3.eventID = createEventObj.eventID;
            eventJudgeObj3.judgeID = createEventObj.judge3ID;

            List <EventJudgeModel> eventJudgeObjList = new List <EventJudgeModel>();

            eventJudgeObjList.Add(eventJudgeObj1);
            eventJudgeObjList.Add(eventJudgeObj2);
            eventJudgeObjList.Add(eventJudgeObj3);

            foreach (var item in eventJudgeObjList)
            {
                Console.WriteLine("item: " + item.eventID + " " + item.judgeID);
            }


            string query = "insert into eventjudge(eventID, judgeID) values(@eventID, @judgeID)";

            SqliteDataAccess.SaveManyObjects(eventJudgeObjList, query);


            return(RedirectToAction("Managment", "Home"));
        }
예제 #2
0
        //Adds member to eventcompetitor if club is in eventclub table
        public ActionResult EnrollMember(CompetitorModel comp)
        {
            //checks if club is allowed to submit members for said event
            EnrolledUserModel obj = new EnrolledUserModel();

            obj.eventID = comp.eventID;
            obj.userID  = (int)HttpContext.Session.GetInt32("UserID");
            string query1 = "select * from eventclub as ec join club as c on ec.clubID = c.clubID where userID = @userID and ec.eventID = @eventID";

            Console.WriteLine("1. " + comp.eventID + " " + comp.userID);
            obj = SqliteDataAccess.SingleObject(obj, query1);

            if (obj == null)
            {
                Console.WriteLine("NULL");
                return(RedirectToAction("Application", "Home"));
            }
            else
            {
                CompetitorModel competitor = new CompetitorModel();
                competitor.userID = comp.userID;
                string query3 = "select * from competitor where userID = @userID";
                competitor         = SqliteDataAccess.SingleObject(competitor, query3);
                competitor.eventID = comp.eventID;

                string query2 = "insert into eventcompetitor(eventID, competitorID) values(@eventID, @competitorID)";
                SqliteDataAccess.SaveSingleObject(competitor, query2);

                for (int i = 1; i < 7; i++)
                {
                    CompetitorModel comp2 = new CompetitorModel();
                    comp2.eventID      = comp.eventID;
                    comp2.competitorID = competitor.competitorID;
                    comp2.jumpnr       = i;
                    competitorList.Add(comp2);
                }
                string query4 = "insert into jump(eventID, competitorID, jumpnr) values(@eventID, @competitorID, @jumpnr)";
                SqliteDataAccess.SaveManyObjects(competitorList, query4);
            }
            return(RedirectToAction("Application", "Home"));
        }