Пример #1
0
 public FavouriteLocation AddFavouriteLocation(FavouriteLocationBindingModel model, int userId)
 {
     try
     {
         FavouriteLocation favouriteLocation = new FavouriteLocation(); // { FormattedAddress = model.FormattedAddress, PlaceId = model.PlaceId, User_Id = userId };
         Mapper.Map(model, favouriteLocation);
         favouriteLocation.User_Id = userId;
         _dbContext.FavouriteLocations.Add(favouriteLocation);
         _dbContext.SaveChanges();
         return(favouriteLocation);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
        public bool UnFavouriteLocation(int id)
        {
            try
            {
                FavouriteLocation loc = _dbContext.FavouriteLocations.FirstOrDefault(x => x.IsDeleted == false && x.Id == id);
                if (loc != null)
                {
                    loc.IsDeleted = true;
                }
                else
                {
                    return(false);
                }

                _dbContext.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }