コード例 #1
0
ファイル: ResultController.cs プロジェクト: cgenin7/Jojoscar
        private List <ResultModel> GetResults(int year, bool excludeNotEligibleForMoney)
        {
            List <ResultModel> results;

            var categories = CategoriesBusinessCtrl.GetCategories(year);

            var    guests        = GuestsBusinessCtrl.GetGuests(year);
            double amountToShare = Calculation.CalculateAmmountToShare(guests, categories);

            Calculation.CalculateResults(guests, categories, GetPercents(), out results, excludeNotEligibleForMoney);

            return(results);
        }
コード例 #2
0
ファイル: ResultController.cs プロジェクト: cgenin7/Jojoscar
        public ActionResult AcademyVotes(int year, AcademyChoiceViewModel academyChoice)
        {
            ViewBag.Year = year;
            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(academyChoice.Php))
                {
                    List <CategoryNomineeModel> nomineesList;
                    Dictionary <string, CategoryNomineeModel> infos = FormatVotes.GetCategoriesFromPhp(academyChoice.Php, CategoriesBusinessCtrl.GetCategories(year), out nomineesList);

                    CategoriesBusinessCtrl.ReplaceCategoryNominees(year, nomineesList);
                }
                else
                {
                    if (!string.IsNullOrEmpty(academyChoice.AcademyVotes))
                    {
                        academyChoice.Categories = CategoriesBusinessCtrl.GetCategoriesWithNominees(year)
                                                   .Select(c => new CategoryViewModel {
                            Category = c
                        }).ToList();
                        var choices = academyChoice.AcademyVotes.Split(',');
                        if (choices != null && choices.Length == Calculation.NB_CATEGORIES)
                        {
                            for (int c = 0; c < choices.Length; c++)
                            {
                                CategoryModel category   = academyChoice.Categories[c].Category;
                                var           dbCategory = CategoriesBusinessCtrl.GetCategory(year, category.CategoryNb);
                                dbCategory.AcademyChoiceLetter = choices[c];
                                CategoriesBusinessCtrl.EditCategory(year, dbCategory);
                            }
                        }
                        else
                        {
                            foreach (CategoryViewModel category in academyChoice.Categories)
                            {
                                var dbCategory = CategoriesBusinessCtrl.GetCategory(year, category.Category.CategoryNb);
                                dbCategory.AcademyChoiceLetter = "";
                                CategoriesBusinessCtrl.EditCategory(year, dbCategory);
                            }
                        }
                    }
                    else
                    {
                        foreach (CategoryViewModel category in academyChoice.Categories)
                        {
                            var dbCategory = CategoriesBusinessCtrl.GetCategory(year, category.Category.CategoryNb);
                            dbCategory.AcademyChoiceLetter = category.Category.AcademyChoiceLetter;
                            CategoriesBusinessCtrl.EditCategory(year, dbCategory);
                        }
                    }
                }
                return(RedirectToAction("AcademyVotes"));
            }

            return(View(academyChoice));
        }