Exemplo n.º 1
0
        public ActionResult Configuration()
        {
            List<TeamRatings> tr = _teamRatingsRepository.GetAll().OrderBy(x=>x.NumberOfMembers).ToList();
            if (tr.Count() == 0)
            {
                TeamRatings team = new TeamRatings();
                team.NumberOfMembers = 1;
                team.MaxScore = 100;
                team.Id = 1;
                tr.Add(team);
            }
            ViewBag.TeamRatings = tr;

            var config = _configRepository.GetAll().FirstOrDefault();
            if (config == null)
            {
                config = new Configuration();
                config.id =1;
                config.RatingDays = 21;
                config.ratingStartDate = 1;
                config.ratingEndDate = 31;
                config.ratingMax = 100;
                config.ratingMin = 0;
            }
            ViewBag.Configuration = config;

            return View();
        }
Exemplo n.º 2
0
        public ActionResult TeamRatings(string Command)
        {
            if (Command == "Add")
            {
                int m = _teamRatingsRepository.GetAll().Max(x => x.NumberOfMembers);

                TeamRatings tr = new TeamRatings();
                tr.NumberOfMembers = ++m;
                tr.MaxScore = 0;
                tr.updatedAt = DateTime.Now;
                tr.createdAt = DateTime.Now;
                _teamRatingsRepository.SaveOrUpdate(tr);
            }

            if (Command == "Save")
            {
                for(int i=0; i<Request.Form.Count;i++)
                {
                    string key = Request.Form.GetKey(i);
                    string n = key.Substring(0,4).ToUpper();
                    if (n == "TEAM")
                    {
                        string l = key.Substring(4,key.Length-4);
                        int number = Int32.Parse(l);
                        var tr = _teamRatingsRepository.Get(x => x.NumberOfMembers == number).FirstOrDefault();
                        if (tr == null)
                        {
                            tr = new TeamRatings();
                            tr.createdAt = DateTime.Now;
                        }
                        tr.NumberOfMembers = number;
                        tr.MaxScore = Int32.Parse(Request.Form.Get(i));
                        tr.updatedAt = DateTime.Now;
                        _teamRatingsRepository.SaveOrUpdate(tr);

                    }
                }
            }

            return RedirectToAction("Configuration");
        }