public async Task <CountryDetailsViewModel> FindCountryByIdAsync(int?id)
        {
            Country country = await _context.Countries
                              .Include(x => x.CountryBuildings)
                              .ThenInclude(x => x.Building)
                              .Include(x => x.CountryUnits)
                              .ThenInclude(x => x.Unit)
                              .Include(x => x.CountryInnovations)
                              .ThenInclude(x => x.Innovation)
                              .Include(x => x.CountryBuildingProgresses)
                              .ThenInclude(x => x.Building)
                              .Include(x => x.CountryInnovationProgresses)
                              .ThenInclude(x => x.Innovation)
                              .FirstOrDefaultAsync(m => m.Id == id);

            BattleViewModel battleViewModel = await DisplayBattleDetails(id);

            CountryDetailsViewModel countryDetailsViewModel = new CountryDetailsViewModel(country);

            if (battleViewModel != null)
            {
                countryDetailsViewModel.BattleViewModel = battleViewModel;
            }

            return(countryDetailsViewModel);
        }
 public CountryDetailsPage(Country selectedCountry)
 {
     _selectedCountry = selectedCountry;
     InitializeComponent();
     ViewModel      = Bootstrapper.Container.GetInstance <CountryDetailsViewModel>();
     BindingContext = ViewModel;
 }
Beispiel #3
0
        // GET: Countries/Details/5
        public async Task <ActionResult> Details(Guid id)
        {
            var country = new CountryDetailsViewModel();

            try
            {
                var result = await _countryService.FindById(id);

                if (!result.Success)
                {
                    Alert($"{result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View(country));
                }

                country.CountryCode        = result.Data.Code;
                country.CountryName        = result.Data.Name;
                country.CountryDescription = result.Data.Description;
                country.CountryId          = result.Data.Id;
                country.DateCreated        = result.Data.CreatedAt;
                country.DateLastUpdated    = result.Data.LastUpdated;

                return(View(country));
            }
            catch (Exception ex)
            {
                Alert($"{ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View(country));
            }
        }
Beispiel #4
0
        public async Task <ActionResult> Delete(Guid id, CountryDetailsViewModel request)
        {
            if (!ModelState.IsValid)
            {
                Alert("Bad Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View(request));
            }
            if (id == null)
            {
                Alert($"Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View(request));
            }
            try
            {
                var result = await _countryService.Delete(id);

                if (!result.Success)
                {
                    Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View(request));
                }
                Alert($"Country Deleted Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                Alert($"{ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View(request));
            }
        }
Beispiel #5
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            CountryTableCell        cell  = tableView.DequeueReusableCell(CountryTableCell.Key, indexPath) as CountryTableCell;
            CountryDetailsViewModel model = _models[indexPath.Row];

            cell.UpdateCell(model);

            return(cell);
        }
        public ActionResult Details(Guid id)
        {
            CountryDetailsViewModel viewModel = new CountryDetailsViewModel()
            {
                Country   = _unitOfWork.CountryRepository.Find(id),
                Countries = _unitOfWork.CountryRepository.Get()
            };

            return(View(viewModel));
        }
Beispiel #7
0
        public ItemDetailPage()
        {
            InitializeComponent();

            var item = new Item
            {
                Text        = "Item 1",
                Description = "This is an item description."
            };

            viewModel      = new CountryDetailsViewModel();
            BindingContext = viewModel;
        }
Beispiel #8
0
        public void UpdateCell(CountryDetailsViewModel country)
        {
            StyleUtil.InitLabelWithSpacing(CountryNameLabel, StyleUtil.FontType.FontRegular, country.Name, 1.14, 16, 28);
            CheckboxImage.Image = (country.Checked ? UIImage.FromBundle("CheckboxChecked") : UIImage.FromBundle("CheckboxUnchecked"));

            if (country.Checked)
            {
                AccessibilityTraits |= UIAccessibilityTrait.Selected;
            }
            else
            {
                AccessibilityTraits &= ~UIAccessibilityTrait.Selected;
            }
        }
        public async Task <CountryDetailsViewModel> GetCountryAsync(int countryId)
        {
            HttpResponseMessage response = await _httpClient.GetAsync($"country/get-country/{countryId}");

            if (response.IsSuccessStatusCode)
            {
                string jsonString = await response.Content.ReadAsStringAsync();

                CountryDetailsViewModel countryDetailsViewModel = JsonSerializer.Deserialize <CountryDetailsViewModel>(jsonString, JsonSerializerOptions);
                return(countryDetailsViewModel);
            }

            throw new ApplicationException($"{response.ReasonPhrase}: The status code is: {(int)response.StatusCode}");
        }
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            CountryDetailsViewModel countryDetailsViewModel = await _countryService.FindCountryByIdAsync(id);

            if (countryDetailsViewModel == null)
            {
                return(NotFound());
            }

            return(View(countryDetailsViewModel));
        }
Beispiel #11
0
        public async Task CheckIfGetCountryViewModelByIdAsyncWorksCorrectly()
        {
            this.SeedDatabase();

            var expectedModel = new CountryDetailsViewModel
            {
                Id   = this.firstCountry.Id,
                Name = this.firstCountry.Name,
            };

            var viewModel = await this.countriesService.GetViewModelByIdAsync <CountryDetailsViewModel>(this.firstCountry.Id);

            var expectedObj     = JsonConvert.SerializeObject(expectedModel);
            var actualResultObj = JsonConvert.SerializeObject(viewModel);

            Assert.Equal(expectedObj, actualResultObj);
        }
Beispiel #12
0
        public ActionResult <CountryDetailsViewModel> Create(CountryDetailsViewModel country, int organizationId)
        {
            var organization = _organizationRepository.GetItemById(organizationId, null);

            if (ModelState.IsValid)
            {
                if (organization != null)
                {
                    var newCountry = _mapper.Map <CountryDetailsViewModel, Country>(country);
                    newCountry.OrganizationId = organizationId;
                    this._countryRepository.Create(newCountry);

                    var createdCountry = _mapper.Map <Country, CountryDetailsViewModel>(newCountry);
                    return(CreatedAtAction(nameof(GetById), new { id = newCountry.Id }, createdCountry));
                }

                return(NotFound(new { Message = "Organization not found!" }));
            }

            return(BadRequest(ModelState));
        }
Beispiel #13
0
 public CountryDetailPage(CountryDetailsViewModel bindingContext)
 {
     InitializeComponent();
     this.BindingContext = bindingContext;
 }
        public async Task <IActionResult> Remove(CountryDetailsViewModel countryDetailsViewModel)
        {
            await this.countriesService.DeleteByIdAsync(countryDetailsViewModel.Id);

            return(this.RedirectToAction("GetAll", "Countries", new { area = "Administration" }));
        }
Beispiel #15
0
        public ItemDetailPage(CountryDetailsViewModel viewModel)
        {
            InitializeComponent();

            BindingContext = this.viewModel = viewModel;
        }