Esempio n. 1
0
        public IActionResult Create(Guid id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            Guid    userId  = new Guid(User.Identity.Name);
            ToWatch toWatch = _db.ToWatch.FirstOrDefault(x => x.MovieId == id && x.UserId == userId);

            if (toWatch != null)
            {
                return(Ok(toWatch));
            }
            ToWatch newFavorite = new ToWatch
            {
                ToWatchId = Guid.NewGuid(),
                MovieId   = id,
                UserId    = userId,
            };

            _db.Add(newFavorite);
            _db.SaveChanges();
            return(Ok(toWatch));
        }
Esempio n. 2
0
 public ToWatch AddToWatch(int movieId, string comment)
 {
     var movie = GetMovieById(movieId);
     var toWatch = new ToWatch()
     {
         User = LoggedInUser,
         Movie = movie,
         Comment = comment ?? ""
     };
     DbEntities.AddToToWatches(toWatch);
     Save();
     return toWatch;
 }
Esempio n. 3
0
    public void Show(string texto, string valor)
    {
        ToWatch item = new ToWatch();

        item.texto = texto;
        item.valor = valor;

        posicion = watches.FindIndex(x => x.texto == texto);

        if (posicion == -1)
        {
            watches.Add(item);
        }
        else
        {
            watches.RemoveAt(posicion);
            watches.Insert(posicion, item);
        }
    }