Beispiel #1
0
        // GET: Entry/Create
        public ActionResult RoundCreate(int id)
        {
            var Model      = new RoundEntryViewModel();
            var RoundEntry = new RoundEntry();

            RoundEntry.TeamID = id;
            var  RoundsCompleted = (from a in db.RoundEntries where a.TeamID == id select a);
            bool R1    = false;
            bool R2    = false;
            bool Rerun = false;

            foreach (var Round in RoundsCompleted.OrderBy(a => a.Round).ToList())
            {
                if (Round.Round == 1)
                {
                    R1 = true;
                }
                else if (Round.Round == 2)
                {
                    R2 = true;
                }
            }
            if (R1 == true && R2 == true)
            {
                Rerun = true;
            }
            RoundEntry.Rerun        = Rerun;
            RoundEntry.Usable       = true;
            Model.RoundEntryCreated = RoundEntry;
            Model.UserName          = userManager.GetUserName(User);

            return(View(RoundEntry));
        }
Beispiel #2
0
        public async Task <ActionResult> RoundEdit([Bind("EntryID,TeamID,Score,Time,Round,Data,Rerun,Usable,TimeStamp")] RoundEntry roundEntry)
        {
            if (ModelState.IsValid)
            {
                var    TeamNumberBranch   = (from t in db.StudentTeams where t.TeamID == roundEntry.TeamID select t).FirstOrDefault().TeamNumberBranch;
                var    TeamNumberSpecific = (from t in db.StudentTeams where t.TeamID == roundEntry.TeamID select t).FirstOrDefault().TeamNumberSpecific;
                string TeamNumber         = TeamNumberBranch + "-" + TeamNumberSpecific;
                var    PreviousField      = (from r in db.RoundEntries where r.EntryID == roundEntry.EntryID select r).FirstOrDefault().Field;
                await this._hubContext.Clients.All.SendAsync("checkThisScore", PreviousField, roundEntry.Data, roundEntry.Score, roundEntry.EntryID, TeamNumber);

                RoundEntry roundEntrytoUpdate = db.RoundEntries.Where(x => x.EntryID == roundEntry.EntryID).FirstOrDefault();
                if (roundEntrytoUpdate != null)
                {
                    roundEntrytoUpdate.Field             = roundEntry.Field;
                    roundEntrytoUpdate.Time              = roundEntry.Time;
                    roundEntrytoUpdate.Data              = roundEntry.Data;
                    roundEntrytoUpdate.Score             = roundEntry.Score;
                    roundEntrytoUpdate.StudentInitials   = roundEntry.StudentInitials;
                    roundEntrytoUpdate.JudgeConfirmNotes = roundEntry.JudgeConfirmNotes;
                    roundEntrytoUpdate.Round             = roundEntry.Round;
                    roundEntrytoUpdate.Rerun             = roundEntry.Rerun;
                    roundEntrytoUpdate.Usable            = roundEntry.Usable;
                    roundEntrytoUpdate.TimeStamp         = roundEntry.TimeStamp;
                    db.Update(roundEntrytoUpdate);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Competition/1"));
                }
                UpdateTopTen();
            }
            return(View(roundEntry));
        }
        public async Task <IActionResult> PutRoundEntry([FromRoute] int id, [FromBody] RoundEntry roundEntry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != roundEntry.EntryID)
            {
                return(BadRequest());
            }

            _context.Entry(roundEntry).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RoundEntryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #4
0
 private void SetPlaceholderTextColor(RoundEntry view)
 {
     if (string.IsNullOrEmpty(view.Placeholder) == false && view.PlaceholderTextColor != Color.Default)
     {
         Control.Hint = view.Placeholder;
         Control.SetHintTextColor(view.PlaceholderTextColor.ToAndroid());
     }
 }
Beispiel #5
0
        private void SetFont(RoundEntry view)
        {
            UIFont uiFont = Font.Default.ToUIFont();

            if (uiFont != null)
            {
                Control.Font = UIFont.FromName(uiFont.Name, (nfloat)view.FontSize);
            }
        }
        public ActionResult RoundCreateBlank([Bind("TeamID,Score,Time,Round,Data,Rerun,Usable,TimeStamp,Field")] RoundEntry roundEntry)
        {
            db.RoundEntries.Add(roundEntry);
            db.SaveChanges();
            this._hubContext.Clients.All.SendAsync("initFieldView", roundEntry.Field, 3);

            string page = roundEntry.TeamID.ToString();

            page = "Details/" + page;
            return(RedirectToAction(page));
        }
Beispiel #7
0
 void SetPlaceholderTextColor(RoundEntry view)
 {
     if (string.IsNullOrEmpty(view.Placeholder) == false && view.PlaceholderTextColor != Color.Default)
     {
         NSAttributedString placeholderString = new NSAttributedString(view.Placeholder, new UIStringAttributes()
         {
             ForegroundColor = view.PlaceholderTextColor.ToUIColor()
         });
         Control.AttributedPlaceholder = placeholderString;
     }
 }
        public async Task <IActionResult> PostRoundEntry([FromBody] RoundEntry roundEntry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.RoundEntries.Add(roundEntry);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRoundEntry", new { id = roundEntry.EntryID }, roundEntry));
        }
Beispiel #9
0
        private void SetBorder(RoundEntry view)
        {
            Control.Layer.BorderWidth = view.BorderWidth;
            Control.BorderStyle       = (view.BorderWidth == 0) ? UITextBorderStyle.None : UITextBorderStyle.RoundedRect;

            Control.Layer.BorderColor = view.BorderColor.ToCGColor();
            if (view.BorderRadius > 0)
            {
                Control.Layer.CornerRadius      = view.BorderRadius;
                Control.Layer.MasksToBounds     = true;
                Control.Layer.SublayerTransform = CATransform3D.MakeTranslation(view.BorderRadius, 0, 0);
            }
        }
Beispiel #10
0
        // GET: Entry/Edit/5*/
        public ActionResult RoundEdit(int id)
        {
            if (id == null)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            RoundEntry score = db.RoundEntries.Find(id);

            if (score == null)
            {
                //return HttpNotFound();
            }
            return(View(score));
        }
Beispiel #11
0
        private void SetBorder(RoundEntry view)
        {
            if (view.BorderRadius > 0)
            {
                var backColor = view.BackgroundColor.ToAndroid();
                view.BackgroundColor = Color.Transparent;

                var gd = new GradientDrawable();
                gd.SetColor(backColor);
                gd.SetCornerRadius(view.BorderRadius);
                gd.SetStroke(1, view.BorderColor.ToAndroid());

                Control.SetBackgroundDrawable(gd);
            }
        }
Beispiel #12
0
        private void SetTextAlignment(RoundEntry view)
        {
            switch (view.XAlign)
            {
            case Xamarin.Forms.TextAlignment.Center:
                Control.Gravity = GravityFlags.Center;
                break;

            case Xamarin.Forms.TextAlignment.End:
                Control.Gravity = GravityFlags.End;
                break;

            case Xamarin.Forms.TextAlignment.Start:
                Control.Gravity = GravityFlags.Start;
                break;
            }
        }
Beispiel #13
0
        private void SetTextAlignment(RoundEntry view)
        {
            switch (view.XAlign)
            {
            case TextAlignment.Center:
                Control.TextAlignment = UITextAlignment.Center;
                break;

            case TextAlignment.End:
                Control.TextAlignment = UITextAlignment.Right;
                break;

            case TextAlignment.Start:
                Control.TextAlignment = UITextAlignment.Left;
                break;
            }
        }
Beispiel #14
0
        public ActionResult RoundCreate([Bind("TeamID,Score,Time,Round,Data,Rerun,Usable,TimeStamp,Field,JudgeConfirmNotes,StudentInitials")] RoundEntry roundEntry)
        {
            Random random = new Random();

            roundEntry.EntryID = random.Next(1, 100000);
            db.RoundEntries.Add(roundEntry);
            db.SaveChanges();

            var    TeamNumberBranch   = (from t in db.StudentTeams where t.TeamID == roundEntry.TeamID select t).FirstOrDefault().TeamNumberBranch;
            var    TeamNumberSpecific = (from t in db.StudentTeams where t.TeamID == roundEntry.TeamID select t).FirstOrDefault().TeamNumberSpecific;
            string TeamNumber         = TeamNumberBranch + "-" + TeamNumberSpecific;

            this._hubContext.Clients.All.SendAsync("initFieldView", roundEntry.Field, 3, roundEntry.Score, TeamNumber, false, false, "0/0/0/0/0^0/0/0/0^0/0^0/0");
            this._hubContext.Clients.All.SendAsync("checkThisScore", roundEntry.Field, roundEntry.Data, roundEntry.Score, roundEntry.EntryID, TeamNumber);
            UpdateTopTen();
            string page = roundEntry.TeamID.ToString();

            page = "Details/" + page;
            return(RedirectToAction(page));
        }
Beispiel #15
0
 private void SetFont(RoundEntry view)
 {
     Control.SetTextSize(ComplexUnitType.Sp, (float)view.FontSize);
 }