Exemple #1
0
 public DataAccess.UserGame Map3(Library.UserGame userGame) => new DataAccess.UserGame
 {
     Review        = userGame.Review,
     Score         = userGame.Score,
     DatePurchased = userGame.PurchaseDate,
     GameId        = userGame.Game.GameId,
     UserName      = userGame.User.UserName,
 };
Exemple #2
0
 //had to make two maps since the IEnumerable Mapper was giving me error
 public static DataAccess.UserGame Map(Library.UserGame userGame) => new DataAccess.UserGame
 {
     //GameId = userGame.Game.GameId,
     //UserName = userGame.User.UserName,
     Game = Mapper.Map(userGame.Game),
     UserNameNavigation = Mapper.Map(userGame.User),
     Review             = userGame.Review,
     Score         = userGame.Score,
     DatePurchased = userGame.PurchaseDate,
 };
Exemple #3
0
 //had to make two maps since the IEnumerable Mapper was giving me error
 public DataAccess.UserGame Map2(Library.UserGame userGame) => new DataAccess.UserGame
 {
     //GameId = userGame.Game.GameId,
     //UserName = userGame.User.UserName,
     Game = _db.Game.Find(userGame.Game.GameId),
     UserNameNavigation = _db.User.Find(userGame.User.UserName),
     Review             = userGame.Review,
     Score         = userGame.Score,
     DatePurchased = userGame.PurchaseDate,
 };
Exemple #4
0
 public Library.UserGame GetUserGame(string username, int gameid)
 {
     //shouldn't ever be multiple elements returned
     DataAccess.UserGame ug = _db.UserGame.Include("Game").Include("UserNameNavigation").Where(a => a.UserName == username && a.GameId == gameid).First();
     if (ug == null)
     {
         return(null);
     }
     Library.UserGame lug = Mapper.Map(ug);
     lug.Game.Tags = GetGameTags(gameid);
     return(lug);
 }
Exemple #5
0
        public Library.UserGame GetReviewByUserGame(string username, int id)
        {
            //var tags = _db.Tag.Include(t => t.TagId).ThenInclude(t => t.)
            var usergame = _db.UserGame.Include(g => g.Game).Include("UserNameNavigation").Where(ug => ug.UserName == username && ug.GameId == id).First();

            if (usergame == null)
            {
                return(null);
            }

            Library.UserGame libusergame = Mapper.Map(usergame);
            libusergame.Game.Tags = GetGameTags(libusergame.Game.GameId);
            return(libusergame);
        }
Exemple #6
0
        /// <summary>
        /// deletes the review by setting it's values equal to null for the given UserGame
        /// </summary>
        /// <param name="review"></param>
        /// <returns></returns>

        public bool DeleteReview(Library.UserGame review)
        {
            DataAccess.UserGame ug = _db.UserGame.Where(a => a.UserName == review.User.UserName && a.GameId == review.Game.GameId).First();
            if (ug != null)
            {
                ug.Score  = null; //review.Score;
                ug.Review = null; //review.Review;

                _db.Entry(_db.UserGame.Find(ug.UserName, ug.GameId)).CurrentValues.SetValues(ug);
                // _db.UserGame.Update(ug);
                _db.SaveChanges();
                return(true);
            }
            return(false);
        }
Exemple #7
0
 public bool AddUserGame(Library.UserGame userGame)
 {
     try
     {
         if (_db.Game.Find(userGame.Game.GameId) == null || _db.User.Find(userGame.User.UserName) == null)
         {
             return(false);
         }
         //had to make two maps since the IEnumerable Mapper was giving me error
         _db.UserGame.Add(Map2(userGame));
         _db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #8
0
        public bool UpdateUserGame(Library.UserGame userGame)
        {
            try
            {
                //_db.UserGame.First(a => a.UserName == userGame.User.UserName && a.GameId == userGame.Game.GameId);
                if (_db.Game.Find(userGame.Game.GameId) == null || _db.User.Find(userGame.User.UserName) == null)
                {
                    return(false);
                }
                //had to make two maps since the IEnumerable Mapper was giving me error

                _db.Entry(_db.UserGame.Find(userGame.Game.GameId, userGame.User.UserName))
                .CurrentValues.SetValues(Map2(userGame));
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #9
0
        public bool AddReview(Library.UserGame review)
        {
            bool success = true;

            try
            {
                //this wouldn't work unless we .Include the UserGame along with the user
                //User user = _db.User.Find(review.User.UserName);
                //DataAccess.UserGame usergame = Map3(review);
                DataAccess.UserGame usergame = _db.UserGame.First(a => a.UserName == review.User.UserName && a.GameId == review.Game.GameId);
                usergame.Score  = review.Score;
                usergame.Review = review.Review;
                //_db.Entry(_db.UserGame.Find(usergame.GameId, usergame.UserName)).CurrentValues.SetValues(usergame);
                _db.UserGame.Update(usergame);
                _db.SaveChanges();
                return(success);
            }
            catch
            {
                success = false;
                return(success);
            }
        }
Exemple #10
0
        public Library.FullUserGame GetFullUserGame(string username, int id)
        {
            Library.UserGame   titanug   = new Library.UserGame();
            Library.Game       titangame = new Library.Game();
            Library.Developer  titandev  = new Library.Developer();
            List <Library.Dlc> titandlc  = new List <Library.Dlc>();

            titanug   = GetUserGame(username, id);
            titangame = GetGame(id);
            int n = (int)titangame.DeveloperId;

            titandev = GetDeveloper(n);
            titandlc = GetDlcbyUserGame(username, id).ToList();

            Library.FullUserGame titan = new Library.FullUserGame
            {
                Developer = titandev,
                Game      = titangame,
                Dlcs      = titandlc,
                UserGame  = titanug,
            };

            return(titan);
        }
Exemple #11
0
 public bool UpdateReview(Library.UserGame review)
 {
     return(this.AddReview(review));
 }