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)); }
public ActionResult GenerateVoteFile(int year) { ViewBag.Year = year; var guests = GuestsBusinessCtrl.GetGuests(year); FormatVotes.CreateDoc("D:\\Votes" + year + ".doc", CategoriesBusinessCtrl.GetCategoriesWithNominees(year), guests); return(View("Index", guests)); }