示例#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);
        }
        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);
        }
 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));
 }
        private static IReadOnlyList <AwardType> GetAwardTypes(AwardCategory awardCategory)
        {
            if (awardCategory == null)
            {
                throw new ArgumentNullException(nameof(awardCategory));
            }

            return(AwardType.ValidAwardTypes
                   .Where(at => at.AwardCategory == awardCategory)
                   .ToList());
        }
 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());
 }
        // 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
        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();
        }
 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");
 }
 protected AwardTypeParameterBase(AwardCategory awardCategory) : base(GetAwardTypes(awardCategory), @"awards")
 {
 }
        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;
        }
 public CategoryNomineesViewModel(IAppNavService navService, AwardCategory awardCategory) : base(navService)
 {
     _categoryNominees = new ObservableCollection <Nominee>();
     this.Category     = awardCategory;
 }