Esempio n. 1
0
 public IActionResult AddToFavourite([FromBody] Favourite favourite)
 {
     if (ModelState.IsValid)
     {
         _favouriteRepository.Add(favourite);
     }
     return(new JsonResult(favourite));
 }
Esempio n. 2
0
        public Favourite Add(Favourite favourite)
        {
            var e = new FavouriteEventArgs {
                Favourite = favourite
            };

            EventManager.Instance.FireBeforeFavourite(this, e);

            if (!e.Cancel)
            {
                favourite = _favouriteRepository.Add(favourite);

                EventManager.Instance.FireAfterFavourite(this, new FavouriteEventArgs {
                    Favourite = favourite
                });
            }

            return(favourite);
        }
        public IActionResult Post([FromBody] DtoFavourite saveFavourite)
        {
            var userEmail = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            var userId = userRepository.GetUserId(userEmail);

            if (repository.Any(saveFavourite.RoomId, userId))
            {
                return(BadRequest("The favourite already exists."));
            }

            var favourite = new Favourite
            {
                AppUserId = userId,
                RoomId    = saveFavourite.RoomId
            };

            repository.Add(favourite);
            return(Ok(favourite));
        }
Esempio n. 4
0
        public ActionResult AddRemovetoFavourites(int id, int sectionid)
        {
            var objFavourite = _repoFavourite.GetSingle(x => x.SectionId == sectionid && x.EntityId == id);

            if (objFavourite == null)
            {
                FavouriteModel objFavouriteModel = new FavouriteModel();

                objFavouriteModel.EntityId      = id;
                objFavouriteModel.SectionId     = sectionid;
                objFavouriteModel.UserProfileId = _repoUserProfile.GetSingle(x => x.UserId == CurrentUser.UserId).Id;
                _repoFavourite.Add(FavouriteMap.Map(objFavouriteModel));
                _repoFavourite.Save();
                return(Json(new { status = "success", message = "added" }));
            }
            else
            {
                _repoFavourite.Delete(objFavourite);
                _repoFavourite.Save();
                return(Json(new { status = "success", message = "removed" }));
            }
        }
Esempio n. 5
0
 public Favourite Add(Favourite dialogueFavourite)
 {
     return(_favouriteRepository.Add(dialogueFavourite));
 }