public async Task <IActionResult> AddFavorite(int propertyId)
        {
            var userId = User.GetUserId();

            if (await _favouriteService.FavouriteExists(userId, propertyId))
            {
                var userFavourite = await _favouriteService.GetFavourite(userId, propertyId);

                _favouriteService.RemoveFavourite(userFavourite);

                return(Ok(_response.Ok("The property has been removed from your favourite list")));
            }

            var favourite = await _favouriteService.AddFavourite(userId, propertyId);

            return(Ok(_response.Ok(favourite)));
        }
Пример #2
0
 public IActionResult GetFavourite(string userId)
 {
     try
     {
         return(Ok(_service.GetFavourite(userId)));
     }
     catch (FavouriteNotFound ex)
     {
         return(Conflict(ex.Message));
     }
 }
Пример #3
0
 public IActionResult Get(int id)
 {
     try
     {
         return(Ok(service.GetFavourite(id)));
     }
     catch (PlayerNotFoundException p)
     {
         return(NotFound(JsonConvert.SerializeObject(p.Message)));
     }
 }
Пример #4
0
        public async Task <IActionResult> GetGenericPage(string LDAPUser_id)
        {
            try
            {
                string dirJson = await _service.GetFavourite(LDAPUser_id).ConfigureAwait(false);

                return(Ok(dirJson));
            }
            catch (Exception ex)
            {
                await _errorlogService.InsertError(Request.GetDisplayUrl(), ControllerContext.ActionDescriptor.ActionName.ToString(), ex.Message, ex.ToString()).ConfigureAwait(false);

                return(StatusCode(500, ex.InnerException));
            }
        }