コード例 #1
0
        public NominationList LoadSurveyExport(AwardCategory awardCategory, FilePath filePath)
        {
            var excel = new ExcelQueryFactory(filePath.Value)
            {
                ReadOnly = true
            };

            IEnumerable <Nomination> nominations;

            if (awardCategory == AwardCategory.QuarterlyAwards)
            {
                nominations = LoadQuarterlyAwardsSurveyExport(excel);
            }
            else if (awardCategory == AwardCategory.SuperStarAwards)
            {
                nominations = LoadSuperStarAwardsSurveyExport(excel);
            }
            else
            {
                throw new NotSupportedException($@"Unsupported award category: {awardCategory.Value}");
            }

            var nominationList = new NominationList(_workingDirectoryPath.AwardsPeriod, nominations);

            SaveSnapshot(nominationList);
            return(nominationList);
        }
コード例 #2
0
        public IActionResult AddNew(AddNewViewModel vm)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var category = new AwardCategory()
                {
                    Category    = vm.Category,
                    Description = vm.Description
                };

                var result = this.Services.SaveCategory(category);
                if (result != null)
                {
                    return(RedirectToAction("Index"));
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
コード例 #3
0
        // It was not possible to bind the Slider value changed to a command,
        // so we are using this function in combination with an event.
        public async Task LoadCategories()
        {
            Func <Task> operation = async() =>
            {
                Categories = await AwardCategory.GetAwardsCategoriesByYear(SelectedYear);
            };

            await ExecuteSafeOperation(operation);
        }
コード例 #4
0
 public IActionResult Post([FromBody] AwardCategory model)
 {
     if (ModelState.IsValid)
     {
         var category = this.Services.SaveCategory(model);
         return(CreatedAtAction("Get", new { id = model.Id }, category));
     }
     return(BadRequest(ModelState));
 }
コード例 #5
0
        private static IReadOnlyList <AwardType> GetAwardTypes(AwardCategory awardCategory)
        {
            if (awardCategory == null)
            {
                throw new ArgumentNullException(nameof(awardCategory));
            }

            return(AwardType.ValidAwardTypes
                   .Where(at => at.AwardCategory == awardCategory)
                   .ToList());
        }
コード例 #6
0
 public IActionResult Put(int id, [FromBody] AwardCategory value)
 {
     if (id == value.Id)
     {
         if (ModelState.IsValid)
         {
             var category = this.Services.SaveCategory(value);
             return(CreatedAtAction("Get", new { id = value.Id }, category));
         }
         return(BadRequest(ModelState));
     }
     return(NotFound());
 }
コード例 #7
0
        // save a category
        public AwardCategory SaveCategory(AwardCategory model)
        {
            if (model.Id == 0)
            {
                Context.AwardCategories.Add(model);
            }
            else if (model.Id > 0)
            {
                // do the updating
            }

            Context.SaveChanges();
            return(model);
        }
コード例 #8
0
ファイル: AwardCategoriesSeeder.cs プロジェクト: gogo4ds/LMDB
        public static void Seed(MoviesContext context)
        {
            var awards     = context.Awards.Local;
            var categories = context.Categories.Local;

            foreach (var a in awards)
            {
                foreach (var c in categories)
                {
                    var awardCategory = new AwardCategory()
                    {
                        AwardId    = a.Id,
                        CategoryId = c.Id
                    };

                    context.AwardCategories.AddOrUpdate(ac => new { ac.AwardId, ac.CategoryId }, awardCategory);
                }
            }

            context.SaveChanges();
        }
コード例 #9
0
 public NominationListContext(INominationListRepository nominationListRepository, AwardCategory awardCategory)
 {
     _repository    = nominationListRepository ?? throw new ArgumentNullException(nameof(nominationListRepository));
     _awardCategory = awardCategory ?? throw new ArgumentNullException(nameof(awardCategory));
 }
コード例 #10
0
 public AwardTypeParameter(AwardCategory awardCategory)
     : base(awardCategory)
 {
     RegisterAbortInput(@"stop");
 }
コード例 #11
0
 protected AwardTypeParameterBase(AwardCategory awardCategory) : base(GetAwardTypes(awardCategory), @"awards")
 {
 }
コード例 #12
0
        public CategoryNomineesPage(AwardCategory item)
        {
            BindingContext = new CategoryNomineesViewModel(DependencyService.Get <IAppNavService>(), item);
            var nomineeList = new ListView
            {
                HasUnevenRows = true,
                ItemTemplate  = new DataTemplate(typeof(NomineesPageDataTemplate))
            };

            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
                nomineeList.SeparatorColor = Color.Default;
                break;

            default:
                nomineeList.SeparatorColor = Color.Black;
                break;
            }

            nomineeList.ItemTapped += async(object sender, ItemTappedEventArgs e) =>
            {
                var result = (Nominee)e.Item;

                if (result == null)
                {
                    return;
                }

                //display an action sheet
                var action = await DisplayActionSheet("Perform an operation", "Cancel", "Vote for " + result.StageName);

                if (action.Contains("Vote"))
                {
                    var vote = new Vote
                    {
                        PhoneIPAdress = DependencyService.Get <IIPAddressManager>().GetIPAddress(),
                        CategoryId    = item.Id,
                        NomineeId     = result.Id
                    };

                    bool voteResult = await DependencyService.Get <IWebServices>().PerformVoting(vote);

                    if (voteResult != false)
                    {
                        await DisplayAlert("Tertiary Music Awards", "Voting succusful", "Ok");

                        await Navigation.PushModalAsync(new MainPage());
                    }
                    else
                    {
                        await DisplayAlert("Tertiary Music Awards", "Sorry you have aready voted for this category or something went wrong", "Ok");

                        await Navigation.PushModalAsync(new MainPage());
                    }
                }
                result = null;
            };

            nomineeList.SetBinding(ItemsView <Cell> .ItemsSourceProperty, "Nominees");
            nomineeList.SetBinding(ItemsView <Cell> .IsVisibleProperty, "IsProcessBusy", converter: new BooleanConverter());

            //declare our progress lable
            var progressLabel = new Label()
            {
                FontSize                = 14,
                FontAttributes          = FontAttributes.Bold,
                TextColor               = Color.Black,
                HorizontalTextAlignment = TextAlignment.Center,
                Text = "Loading Nominees List...."
            };

            //instantiate an initialise our activity indicator
            var activityIndicator = new ActivityIndicator()
            {
                IsRunning = true
            };
            var progessIndicator = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Children          =
                {
                    activityIndicator,
                    progressLabel
                }
            };


            progessIndicator.SetBinding(StackLayout.IsVisibleProperty, "IsProcessBusy");

            var mainLayout = new StackLayout
            {
                Children =
                {
                    nomineeList,
                    progessIndicator
                }
            };

            Content = mainLayout;
        }
コード例 #13
0
 public CategoryNomineesViewModel(IAppNavService navService, AwardCategory awardCategory) : base(navService)
 {
     _categoryNominees = new ObservableCollection <Nominee>();
     this.Category     = awardCategory;
 }