Example #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);
 }