Esempio n. 1
0
 public Contracts.DataModels.Favourite Favourites([FromBody] Favourite model)
 {
     try
     {
         Contracts.Models.Country       country   = AutoMapper.Mapper.Map <Contracts.Models.Country>(_countryRepository.GetByAltId(model.CountryAltId));
         Contracts.DataModels.Favourite favourite = _favouriteRepository.GetByCountryIdAndCreatedBy(model.CountryAltId, model.CreatedBy);
         if (favourite == null)
         {
             favourite = _favouriteRepository.Save(new Contracts.DataModels.Favourite
             {
                 CountryAltId = model.CountryAltId,
                 IsEnabled    = true,
                 CreatedUtc   = DateTime.UtcNow,
                 CreatedBy    = model.CreatedBy
             });
             _activityHelper.SaveActivity("Added to Favourites - " + country.Name, "You have added country " + country.Name + " to your favorite list on " + DateTime.Now.ToString("ddd, dd MMM yyy HH:mm:ss"), model.CreatedBy);
         }
         return(favourite);
     }
     catch (Exception ex)
     {
     }
     return(null);
 }
Esempio n. 2
0
 public CountryDetailResponseViewModel GetCountryDetails(Guid altId)
 {
     try
     {
         CountryDetailResponseViewModel   countryCMSResponseViewModel = new CountryDetailResponseViewModel();
         Contracts.Models.Country         country    = AutoMapper.Mapper.Map <Contracts.Models.Country>(_countryRepository.GetByAltId(altId));
         List <Contracts.Models.Currency> currencies = AutoMapper.Mapper.Map <List <Contracts.Models.Currency> >(_currencyRepository.GetAll(null).ToList());
         List <Contracts.Models.Language> languages  = AutoMapper.Mapper.Map <List <Contracts.Models.Language> >(_languageRepository.GetAll(null).ToList());
         List <Contracts.Models.CountryLanguageMapping> countryLanguageMappings = AutoMapper.Mapper.Map <List <Contracts.Models.CountryLanguageMapping> >(_countryLanguageMappingRepository.GetAll(null).Where(w => w.CountryId == country.Id).ToList());
         List <Contracts.Models.CountryCurrencyMapping> countryCurrencyMappings = AutoMapper.Mapper.Map <List <Contracts.Models.CountryCurrencyMapping> >(_countryCurrencyMappingRepository.GetAll(null).Where(w => w.CountryId == country.Id).ToList());
         return(new CountryDetailResponseViewModel
         {
             Country = country,
             Currencies = currencies,
             Languages = languages,
             CountryCurrencyMappings = countryCurrencyMappings,
             CountryLanguageMappings = countryLanguageMappings
         });
     }
     catch (Exception)
     {
     }
     return(null);
 }