Exemplo n.º 1
0
        //
        // GET: /Meets/Edit/5

        public ActionResult Edit(int id = 0)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Schedule"));
            }
            Meet meet = db.Meets.Find(id);

            if (meet == null)
            {
                return(HttpNotFound());
            }
            return(View(meet));
        }
Exemplo n.º 2
0
 public ActionResult Edit(Meet meet)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(RedirectToAction("Schedule"));
     }
     if (ModelState.IsValid)
     {
         db.Entry(meet).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(meet));
 }
Exemplo n.º 3
0
        // GET: Meets/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Meet meet = db.Meets.Find(id);

            if (meet == null)
            {
                return(HttpNotFound());
            }
            return(View(meet));
        }
Exemplo n.º 4
0
        public ActionResult Create(Meet meet)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Schedule"));
            }
            if (ModelState.IsValid)
            {
                db.Meets.Add(meet);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(meet));
        }
Exemplo n.º 5
0
        public static void CreateMeet(Meet meet, DatabaseConnection db)
        {
            var cmd = new SqlCommand("INSERT INTO Meet (Name, Date, PersonalWeight, IdUser) output INSERTED.ID VALUES('" + meet.Header.Name + "', '" + meet.Header.Date + "', '" + meet.Header.PersonalWeight + "', '" + meet.Header.IdUser + "')", db.connection);

            meet.Header.Id = (int)cmd.ExecuteScalar();
            cmd.Dispose();

            foreach (var result in meet.Results)
            {
                cmd = new SqlCommand("INSERT INTO MeetResult (IdMeet, Name, MovementType, Weight, Success) " +
                                     "VALUES(" + meet.Header.Id + ", '" + result.Name + "', " + result.MovementType + ", " + result.Weight + ", " + Convert.ToInt32(result.Success) + ")", db.connection);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
            }
        }
Exemplo n.º 6
0
 static void Display1(Meet t)
 {
     if (t == Meet.Hello)
     {
         Console.WriteLine("Hii");
     }
     else if (t == Meet.Good_Bye)
     {
         Console.WriteLine("Bye");
     }
     else
     {
         Console.WriteLine("Not ok");
     }
 }
Exemplo n.º 7
0
    public override bool Equals(object obj)
    {
        Meet input = obj as Meet;

        if (obj == null)
        {
            return(false);
        }

        return(MeetId == input.MeetId &&
               MeetName == input.MeetName &&
               MeetDate == input.MeetDate &&
               MeetLocation == input.MeetLocation &&
               MeasurementType == input.MeasurementType);
    }
Exemplo n.º 8
0
        public Meet openMeet(string filePath)
        {
            ISavingSvc saveSvc    = (ISavingSvc)GetService(typeof(ISavingSvc).Name);
            Meet       meetToOpen = saveSvc.openMeet(filePath);

            if (meetToOpen == null)
            {
                MessageBox.Show("Meet did NOT open correctly!");
            }
            else
            {
                MessageBox.Show("Meet opened correctly!");
            }
            return(meetToOpen);
        }
Exemplo n.º 9
0
        public IHttpActionResult UpdateMeet(Meet model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!ValidPoolCodes.Contains(model.PoolLength))
            {
                return(BadRequest("Pool Length must match the neutral file format code"));
            }

            var res = _meetRepo.UpdateMeet(model);

            return(res ? Ok() : (IHttpActionResult)BadRequest("Meet failed to be updated"));
        }
Exemplo n.º 10
0
        public Meet openMeet(string filePath)
        {
            ISavingSvc saveSvc    = (ISavingSvc)GetService(typeof(ISavingSvc).Name);
            Meet       meetToOpen = saveSvc.openMeet(filePath);

            if (meetToOpen == null)
            {
                //null is probably inaccurate here
                ScriptManager.RegisterClientScriptBlock(null, this.GetType(), "Error", "Meet did NOT open correctly!", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(null, this.GetType(), "Success", "Meet opened correctly!", true);
            }
            return(meetToOpen);
        }
Exemplo n.º 11
0
        public async Task <int> Add(MeetDTO dto)
        {
            Meet newMeet = new Meet()
            {
                Address = dto.Address,
                City    = dto.City,
                Date    = dto.Date,
                Title   = dto.Title,
            };

            await _context.AddAsync(newMeet);

            await _context.SaveChangesAsync();

            return(newMeet.Id);
        }
        public void TestMeetOpens()
        {
            Console.WriteLine("Inside " + GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            SavingJsonSvcImpl savingImplObject = new SavingJsonSvcImpl();
            Meet openedMeet = savingImplObject.openMeet(testFileName);

            Console.WriteLine("Opened Meet:");
            Console.WriteLine(openedMeet.ToString());
            Console.WriteLine("\nControl Meet:");
            Console.WriteLine(testMeet.ToString());
            bool test = openedMeet.Equals(testMeet);

            Assert.True(test, GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name + " Failed");
            Console.WriteLine(GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name + " Passed");
        }
Exemplo n.º 13
0
        public void TestOpenMeetMeetMgr()
        {
            Console.WriteLine("Inside " + GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name);

            MeetMgr mMgr       = new MeetMgr();
            Meet    openedMeet = mMgr.openMeet(testFileName);

            Console.WriteLine("Opened Meet:");
            Console.WriteLine(openedMeet.ToString());
            Console.WriteLine("\nControl Meet:");
            Console.WriteLine(testMeet.ToString());
            bool test = openedMeet.Equals(testMeet);

            Assert.True(test, GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name + " Failed");
            Console.WriteLine(GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name + " Passed");
        }
Exemplo n.º 14
0
        public async Task <Response> UnJoinAPlan(int pPlanId, string pUserId)
        {
            var url        = Application.Current.Resources["UrlAPI"].ToString();
            var prefix     = Application.Current.Resources["UrlPrefix"].ToString();
            var controller = "/Meets/DeleteMeet";

            Meet meet = new Meet();

            meet.PlanId = pPlanId;
            meet.UserId = pUserId;

            //Delete meet
            var response = await ApiService.GetInstance().Post <Meet>(url, prefix, controller, meet, Settings.TokenType, Settings.AccessToken);

            return(response);
        }
Exemplo n.º 15
0
        public bool saveMeet(string filePath, Meet meetToSave)
        {
            ISavingSvc saveSvc = (ISavingSvc)GetService(typeof(ISavingSvc).Name);
            bool       didSave = saveSvc.saveMeet(filePath, meetToSave);

            if (!didSave)
            {
                ScriptManager.RegisterClientScriptBlock(null, this.GetType(), "Error", "Meet did NOT save!", true);
                return(false);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(null, this.GetType(), "Success", "Meet saved correctly at: " + filePath, true);
                return(true);
            }
        }
Exemplo n.º 16
0
        public void UpdateMeetInvalidModelReturnsInvalidModelStateResult()
        {
            //Setup
            var mockMeetsRepo = new Mock <IMeetRepo>();
            var meet          = new Meet();
            var sut           = new MeetsController(mockMeetsRepo.Object);

            sut.ModelState.AddModelError("MeetName", "MeetName is required");

            //action
            var res = sut.UpdateMeet(meet);

            //assert
            res.Should().BeOfType <InvalidModelStateResult>();
            res.As <InvalidModelStateResult>().ModelState.IsValid.Should().BeFalse();
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            SetupLogger();
            LangConfig config = new LangConfig()
            {
                NemskaGrupa = false,
                Link        = "https://classroom.google.com/u/1/c/MjEwMzIwNDY5MjYz",
            };

            config.Driver.Browser      = "firefox";
            config.Driver.DriverFolder = "/home/lyubenk/.webdrivers/";
            CancellationTokenSource source = new();

            using (Classroom cr = new Classroom(config, source.Token))
            {
                using (Meet meet = cr.InitMeetInstance(source.Token))
                {
                    try
                    {
                        Task crTask   = cr.Start();
                        Task meetTask = meet.Start();
                        Console.ReadLine();
                        source.Cancel();
                        Task.WaitAll(crTask, meetTask);
                    }
                    catch (AggregateException agex)
                    {
                        foreach (Exception ex in agex.InnerExceptions)
                        {
                            if (ex is TaskCanceledException)
                            {
                                logger.Debug("Successful cancel");
                            }
                            else
                            {
                                logger.Error(ex);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                    }
                }
            }
        }
        public async Task <ActionResult> Edit(Meet meet)
        {
            try
            {
                string        meetJson      = JsonConvert.SerializeObject(meet);
                StringContent bodyPostData  = new StringContent(meetJson, Encoding.UTF8, WebApiHelper.BaseMediaType);
                string        resultRequest = await WebApiHelper.ExecuteWebApiRequest <string>($"api/Meets", WebApiHelper.HttpMethod.POST, bodyPostData);

                ViewData["message"] = resultRequest;

                return(View());
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 19
0
 public void CreateTeamPerfPDF(string teamAbbr, Meet meetToPrint)
 {
     try
     {
         IPrintoutPDFSvc printoutSvc = (IPrintoutPDFSvc)GetService(typeof(IPrintoutPDFSvc).Name);
         bool            didPrint    = printoutSvc.CreateTeamPerfPDF(teamAbbr, meetToPrint);
         if (!didPrint)
         {
             MessageBox.Show("Printout Failed!");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception in PrintoutMgr: CreateTeamPerfPDF: " + e);
         MessageBox.Show("Printout Failed!");
     }
 }
        public async Task <ActionResult> Create(Meet meet)
        {
            try
            {
                /// Конвертация в Json-тело запроса
                string        jsonMeet      = JsonConvert.SerializeObject(meet);
                StringContent bodyPostData  = new StringContent(jsonMeet, Encoding.UTF8, WebApiHelper.BaseMediaType);
                string        resultRequest = await WebApiHelper.ExecuteWebApiRequest <string>($"api/Meets", WebApiHelper.HttpMethod.POST, bodyPostData);

                ViewData["message"] = resultRequest;
                return(Create());
            }
            catch (Exception ex)
            {
                ViewData["message"] = ex.Message;
                return(Create());
            }
        }
Exemplo n.º 21
0
        public void UpdateMeetPoolLengthNotValidReturnsBadRequest()
        {
            //Setup
            var mockMeetsRepo = new Mock <IMeetRepo>();
            var meet          = new Meet()
            {
                PoolLength = "1000"
            };
            var sut = new MeetsController(mockMeetsRepo.Object);


            //action
            var res = sut.UpdateMeet(meet);

            //assert
            res.Should().BeOfType <BadRequestErrorMessageResult>();
            res.As <BadRequestErrorMessageResult>().Message.Should().Be("Pool Length must match the neutral file format code");
        }
Exemplo n.º 22
0
        public async Task <IActionResult> Create(Meet meet)
        {
            try
            {
                // TODO: Add insert logic here
                await _baseEduContext.Meet.AddAsync(meet);

                if (await _baseEduContext.SaveChangesAsync() > 0)
                {
                    return(RedirectToAction(nameof(Index)));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 23
0
        public JsonResult DeleteMeet(DeleteMeetVM vm)
        {
            try
            {
                Meet meet = _ms.GetById(vm.Id);
                meet.IsActive   = false;
                meet.Modified   = DateTime.Now;
                meet.ModifiedBy = SessionManager.ActiveUser.Id;

                _ms.Update(meet);

                return(Json(new { Result = true }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, ex.Message }));
            }
        }
Exemplo n.º 24
0
        public bool CreateMeet(MeetCreate model)
        {
            var entity = new Meet()
            {
                OwnerID           = _userID,
                LocationOfMeet    = model.LocationOfMeet,
                DescriptionOfMeet = model.DescriptionOfMeet,
                DateOfMeet        = model.DateOfMeet,
                DateCreated       = DateTimeOffset.Now
            };


            using (var ctx = new ApplicationDbContext())
            {
                ctx.Meets.Add(entity);
                return(ctx.SaveChanges() == 1);
            };
        }
Exemplo n.º 25
0
        public static void UpdateMeet(Meet meet, DatabaseConnection db)
        {
            var cmd = new SqlCommand("UPDATE Meet SET Date = '" + meet.Header.Date + "', Name = '" + meet.Header.Name + "',  PersonalWeight = " + meet.Header.PersonalWeight + " WHERE Id =" + meet.Header.Id, db.connection);

            cmd.ExecuteNonQuery();
            cmd.Dispose();

            cmd = new SqlCommand("DELETE FROM MeetResult WHERE IdMeet = " + meet.Header.Id, db.connection);
            cmd.ExecuteNonQuery();
            cmd.Dispose();

            foreach (var result in meet.Results)
            {
                cmd = new SqlCommand("INSERT INTO MeetResult (IdMeet, MovementType, Weight, Success, Name) " +
                                     "VALUES(" + meet.Header.Id + ", " + result.MovementType + ", " + result.Weight + ", " + Convert.ToInt32(result.Success) + ", '" + result.Name + "')", db.connection);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
            }
        }
        public async Task AddNewMeetTestAsync(string name, string description, string startDateTime, string endDate)
        {
            /** Make a new database **/
            var testDB = new TestDatabase();

            /** Make a temporary user **/
            var user = new User();

            user.FirstName = "Database";
            user.LastName  = "Tester";
            user.Username  = "******";
            user.Email     = "*****@*****.**";

            Affiliation matchingAffiliation = new Affiliation();

            matchingAffiliation.Abbreviation = "TEST";
            await testDB.AddNewAffiliationAsync(matchingAffiliation);

            user = await testDB.AddNewUserAsync(user);

            /** Make the meet **/
            var newMeet = new Meet();

            newMeet.Name          = name;
            newMeet.Description   = description;
            newMeet.StartDateTime = Convert.ToDateTime(startDateTime);
            newMeet.EndDate       = Convert.ToDateTime(endDate);

            newMeet = await testDB.AddNewMeetAsync(newMeet, user);

            var meetsIEnum = await testDB.RefreshMeetsAsync(user);

            ObservableCollection <Meet> meets = new ObservableCollection <Meet>(meetsIEnum);

            var theMeet = meets.Last();

            Assert.AreEqual(theMeet.Name, name);
            Assert.AreEqual(theMeet.Description, description);
            Assert.AreEqual(theMeet.StartDateTime, Convert.ToDateTime(startDateTime));
            Assert.AreEqual(theMeet.EndDate, Convert.ToDateTime(endDate));
            Assert.AreEqual(theMeet.Id, meets.Count());
            Assert.AreEqual(theMeet.UserId, user.Id);
        }
Exemplo n.º 27
0
        public IActionResult Add(MeetViewModel model, string DurType)
        {
            if (ModelState.IsValid)
            {
                ValidationContext val = new ValidationContext(model);
                var result            = model.Validate(val);
                if (result.Count() > 0)
                {
                    TempData["error"] = result.FirstOrDefault().ErrorMessage;
                    return(RedirectToAction("New"));
                }
                else
                {
                    TimeSpan duration = new TimeSpan();
                    if (DurType == "day")
                    {
                        duration = new TimeSpan((int)model.Duration, 0, 0, 0);
                    }
                    else if (DurType == "hour")
                    {
                        duration = new TimeSpan(0, (int)model.Duration, 0, 0);
                    }
                    else
                    {
                        duration = new TimeSpan(0, 0, (int)model.Duration, 0);
                    }
                    DateTime dateValue = new DateTime(model.Date.Year, model.Date.Month, model.Date.Day, model.Time.Hour, model.Time.Minute, model.Time.Second);
                    Meet     NewMeet   = new Meet
                    {
                        Title       = model.Title,
                        Description = model.Description,
                        Date        = dateValue,
                        Duration    = duration,
                        UserId      = GetCurrentUserAsync().Result.Id,
                    };

                    _context.Meets.Add(NewMeet);
                    _context.SaveChanges();
                    return(Redirect($"/activity/{NewMeet.MeetId}"));
                }
            }
            return(View("AddActivity"));
        }
Exemplo n.º 28
0
        public void setupMeetObject()
        {
            Performance myPerformance1 = new Performance("A", "AA", 1.1m);
            Performance myPerformance2 = new Performance("B", "BB", 2.2m);
            Performance myPerformance3 = new Performance("C", "CC", 3.3m);
            Performance myPerformance4 = new Performance("D", "AA", 4.1m);
            Performance myPerformance5 = new Performance("E", "BB", 5.2m);
            Performance myPerformance6 = new Performance("F", "CC", 6.3m);

            List <Performance> myPerformancesA = new List <Performance>();

            myPerformancesA.Add(myPerformance1);
            myPerformancesA.Add(myPerformance2);
            myPerformancesA.Add(myPerformance3);

            List <Performance> myPerformancesB = new List <Performance>();

            myPerformancesB.Add(myPerformance4);
            myPerformancesB.Add(myPerformance5);
            myPerformancesB.Add(myPerformance6);

            Dictionary <string, List <Performance> > myPerformances = new Dictionary <string, List <Performance> >();

            myPerformances.Add("Boy's 100", myPerformancesA);
            myPerformances.Add("Boy's 200", myPerformancesB);

            Dictionary <string, string> boysNames = new Dictionary <string, string>();

            boysNames.Add("BLN", "Baldwin");
            boysNames.Add("TJ", "Thomas Jefferson");
            boysNames.Add("WHS", "Washington HS");

            Dictionary <string, string> girlsNames = new Dictionary <string, string>();

            girlsNames.Add("PLM", "Plum");
            girlsNames.Add("GWY", "Gateway");
            girlsNames.Add("KCH", "Knoch");

            Teams teams = new Teams(boysNames, girlsNames);

            testMeet = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams, myPerformances);
        }
Exemplo n.º 29
0
    protected void cmdOpen_Click(object sender, EventArgs e)
    {
        panAlert.Visible         = true;
        panDatabaseAlert.Visible = false;

        DatabaseMgr dm         = new DatabaseMgr();
        Meet        openedMeet = dm.FindMeet(meetID);

        if (openedMeet != null)
        {
            Session["ActiveMeet"] = openedMeet;

            //Open MeetHub here
            Response.Redirect("MeetHub.aspx");
        }
        else
        {
            lblAlert.Text = "Unknown error loading meet from database";
        }
    }
Exemplo n.º 30
0
        public bool AddPerformances(Meet meet)
        {
            int  meetID = FindMeetId(meet);
            bool didAdd = false;

            if (meet.schoolNames.boySchoolNames != null)
            {
                SqlConnection conn = null;
                try
                {
                    conn = GetConnection();
                    conn.Open();
                    foreach (string eventName in meet.performances.Keys)
                    {
                        foreach (Performance perf in meet.performances[eventName])
                        {
                            string     correctEvent = eventName.Replace("'", "");
                            string     SqlQuery     = "insert into Performances (AthleteName, SchoolName, EventName, HeatNum, Performance, MeetKey) values ('" + perf.athleteName + "', '" + perf.schoolName + "', '" + correctEvent + "', '" + perf.heatNum + "', '" + perf.performance + "', '" + meetID + "')";
                            SqlCommand cmd          = new SqlCommand(SqlQuery, conn);
                            int        numberOfRows = cmd.ExecuteNonQuery();
                        }
                    }

                    didAdd = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception: " + e);
                }
                finally
                {
                    conn.Close();
                }
            }
            //performances MAY be null.
            {
                didAdd = true;
            }

            return(didAdd);
        }
Exemplo n.º 31
0
 public override void Given()
 {
     meet = season.Divisions.First().Meets.First();
       repository.Setup(r => r.Get<Meet>(meet.Id)).Returns(meet);
 }
Exemplo n.º 32
0
 public override void Given()
 {
     user = users.Skip(2).First();
       authenticationService.MockPrincipal.User = user;
       skillLevel = user.SkillLevels.Where(sl => sl.GameType == season.GameType).First().Value;
       team = teams.Where(t => t.Players.Contains(user)).Single();
       teammate = team.Players.Where(p => p != user).Single();
       lastMeet = meets.Where(m => m.Teams.Contains(team) && m.IsComplete).OrderByDescending(m => m.Week).First();
       seasonResultsCount = (from m in meets
                     where m.Teams.Contains(team) && m.IsComplete
                     from match in m.Matches
                     where match.Players.Where(p => p.Player == user).Any()
                     select match).Count();
 }