public ActionResult Like(int id, bool status)
        {
            var Db = new LikeDislike();  //created datafunction.cs   and there implemented  like function

            //favar result = Db.Like(id, status);  // calling and sending data to  like function using Db
            return(View());
        }
Esempio n. 2
0
        public async Task <ActionResult <LikeDislike> > PostLikeDislike(LikeDislike likeDislike)
        {
            _context.LikeDislike.Add(likeDislike);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLikeDislike", new { id = likeDislike.Id }, likeDislike));
        }
Esempio n. 3
0
        public async Task LikeOrDislikeThreadAsync(int threadId, bool isLike, string username)
        {
            var threadsRepository = _unitOfWork.GetRepository <Thread>();
            var thread            = await threadsRepository.GetFirstOrDefaultAsync(t => t.Id == threadId, t => t.Author, t => t.Section);

            var usersRepository = _unitOfWork.UserRepository;
            var author          = await usersRepository.GetFirstOrDefaultAsync(u => u.Username == username);

            var likesRepository = _unitOfWork.GetRepository <LikeDislike>();
            var currentLike     = await likesRepository.GetFirstOrDefaultAsync(l => l.ThreadId == threadId && l.User == author, l => l.Thread, l => l.User);

            if (currentLike == null)
            {
                currentLike = new LikeDislike
                {
                    User   = author,
                    Thread = thread,
                    IsLike = isLike
                };

                likesRepository.Create(currentLike);
            }
            else if (currentLike.IsLike != isLike)
            {
                currentLike.IsLike = isLike;

                likesRepository.Update(currentLike);
            }
            else
            {
                likesRepository.Delete(currentLike);
            }

            await _unitOfWork.SaveAsync();
        }
Esempio n. 4
0
        public async Task <IActionResult> PutLikeDislike(int id, LikeDislike likeDislike)
        {
            if (id != likeDislike.Id)
            {
                return(BadRequest());
            }

            _context.Entry(likeDislike).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LikeDislikeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 5
0
        public async Task <ServiceResult <ThreadInfo, LikeDislikeThreadError> > LikeDislikeThread(int threadId, string username, bool isLike)
        {
            var userRepository = _unitOfWork.GetRepository <User>();
            var user           = await userRepository.FirstOrDefaultAsync(s => s.Username == username);

            if (user == null)
            {
                return(ServiceResult <ThreadInfo, LikeDislikeThreadError> .CreateFailed(LikeDislikeThreadError.UserNotFound));
            }

            var threadRepository = _unitOfWork.GetRepository <Thread>();
            var thread           = await threadRepository.FirstOrDefaultAsync(t => t.Id == threadId, t => t.Author);

            if (thread == null)
            {
                return(ServiceResult <ThreadInfo, LikeDislikeThreadError> .CreateFailed(LikeDislikeThreadError.ThreadNotFound));
            }

            var likesRepository = _unitOfWork.GetRepository <LikeDislike>();
            var currentLike     = await likesRepository.FirstOrDefaultAsync(l => l.ThreadId == threadId && l.User == user, l => l.Thread, l => l.User);

            if (currentLike == null)
            {
                currentLike = new LikeDislike
                {
                    User   = user,
                    Thread = thread,
                    IsLike = isLike
                };

                likesRepository.Create(currentLike);
            }
            else if (currentLike.IsLike != isLike)
            {
                currentLike.IsLike = isLike;

                likesRepository.Update(currentLike);
            }
            else
            {
                likesRepository.Delete(currentLike);
            }

            await _unitOfWork.SaveAsync();

            var updatedThread = await threadRepository.FirstOrDefaultAsync(t => t.Id == thread.Id, t => t.Author, t => t.Likes, t => t.Section);

            var result = new ThreadInfo
            {
                Id                  = updatedThread.Id,
                Title               = updatedThread.Title,
                Content             = updatedThread.Content,
                SectionName         = updatedThread.Section.Name,
                CreationDateTimeUtc = updatedThread.CreationDateTimeUtc,
                AuthorUsername      = updatedThread.Author.Username,
                LikesDislikes       = updatedThread.Likes.Where(l => l.IsLike).Count() - thread.Likes.Where(l => !l.IsLike).Count()
            };

            return(ServiceResult <ThreadInfo, LikeDislikeThreadError> .CreateSuccess(result));
        }
        public ActionResult details(int boatId) //id is threadid this id we are getting from other page index
        {
            var l = new LikeDislike();

            ViewBag.like               = l.Getlikecounts(boatId);
            ViewBag.Dislike            = l.Getdislikecounts(boatId);
            ViewBag.AllUserlikedislike = l.GetallUser(boatId);
            return(View());
        }
        public ActionResult BoatPopularity()
        {
            var id = Request.RequestContext.HttpContext.Session["userId"];

            ViewBag.Message = id;
            LikeDislike ld = new LikeDislike();
            BoatModel   m  = new BoatModel();

            m.popularityList = ld.getPopularity();
            m.locationList   = BL.MainClass.Instance.getLocations();
            return(View(m));
        }
        public JsonModel DislikePost([FromBody] JsonModel json)
        {
            JsonModel jsonModel = new JsonModel();

            try
            {
                LikeDislike like = JsonConvert.DeserializeObject <LikeDislike>(json.Data.ToString());
                jsonModel = _IFeedBack.DislikePost(like);
            }
            catch (Exception ex)
            {
                jsonModel.Status  = false;
                jsonModel.Message = ex.Message;
                jsonModel.Data    = null;
            }
            return(jsonModel);
        }
Esempio n. 9
0
        public JsonModel DislikePost(LikeDislike likeDislike)
        {
            JsonModel jsonModel = new JsonModel();

            try
            {
                var result = 0;
                var data   = DbContext.LikeDislikes.Where(x => x.CommentUniqueCode == likeDislike.CommentUniqueCode).FirstOrDefault();
                if (data != null)
                {
                    data.CmntDislike = data.CmntDislike + 1;;
                    DbContext.Entry(likeDislike).State = EntityState.Modified;
                    result = DbContext.SaveChanges();
                }
                else
                {
                    likeDislike.CmntDislike = 1;
                    DbContext.LikeDislikes.Add(likeDislike);
                    result = DbContext.SaveChanges();
                }

                if (result > 0)
                {
                    jsonModel.Status  = true;
                    jsonModel.Message = "Successful";
                    jsonModel.Data    = likeDislike;
                }
                else
                {
                    jsonModel.Status  = false;
                    jsonModel.Message = "Failed";
                    jsonModel.Data    = null;
                }
            }
            catch (Exception ex)
            {
                jsonModel.Status  = false;
                jsonModel.Message = ex.Message;
                jsonModel.Data    = null;
            }
            return(jsonModel);
        }
Esempio n. 10
0
        public void Like(LikeDislike likeDislike)
        {
            var liked = Db.FirstOrDefault <Models.DataModels.LikeState>("WHERE [UserId] = @0 AND [AnswerId] = @1", likeDislike.UserId, likeDislike.AnswerId);

            if (liked == null)
            {
                var addLike = new Models.DataModels.LikeState
                {
                    AnswerId  = likeDislike.AnswerId,
                    UserId    = likeDislike.UserId,
                    Sentiment = likeDislike.Sentiment
                };

                Db.Insert("LikeDislike", addLike);
            }
            else
            {
                liked.Sentiment = likeDislike.Sentiment;
                Db.Update(liked);
            }
        }
Esempio n. 11
0
        public JsonResult DisLike(long eventId)
        {
            User    user    = UserHelpers.GetCurrentUser(Session);
            Boolean success = false;
            int     state   = EventZoneConstants.NotRate;

            if (user != null)
            {
                LikeDislike findlike = UserDatabaseHelper.Instance.FindLike(user.UserID, eventId);
                if (findlike != null)
                {
                    state = findlike.Type;
                }
                success = UserDatabaseHelper.Instance.InsertDislike(user.UserID, eventId);
            }
            return(Json(new
            {
                success = success,
                state = state
            }));
        }
Esempio n. 12
0
        public async Task <News> LikeDislike(string token, int newsId, bool isLiked)
        {
            var likeDislike = await _context.LikesDislikes.FirstOrDefaultAsync(e => !e.SoftDeleted && e.Token == token && e.NewsId == newsId);

            var news = await _context.News.FirstOrDefaultAsync(e => !e.SoftDeleted && e.Id == newsId);

            if (news == null)
            {
                throw new NotFoundException("Xeber tapılmadı");
            }

            if (likeDislike == null)
            {
                if (isLiked)
                {
                    news.Like += 1;
                }
                else
                {
                    news.Dislike += 1;
                }
                LikeDislike newLikeDislike = new LikeDislike
                {
                    Token   = token,
                    NewsId  = newsId,
                    IsLiked = isLiked
                };
                await _context.LikesDislikes.AddAsync(newLikeDislike);

                await _context.SaveChangesAsync();
            }
            else
            {
                throw new InvalidInputException("Bir xebere iki defe like veya dislike vermez olmaz!");
            }
            return(news);
        }
Esempio n. 13
0
 public void Like([FromBody] LikeDislike likeDislike)
 {
     SolutionService.Like(likeDislike);
 }
Esempio n. 14
0
        public string Like(int boatId, bool status, int userId)
        {
            var             boat   = db.Boat.FirstOrDefault(x => x.id == boatId);
            var             toggle = false;
            LikeDislikeBoat like   = db.LikeDislikeBoat.FirstOrDefault(x => x.boatId == boatId && x.userid == userId);

            // here we are checking whether user have done like or dislike
            if (like == null)
            {
                like        = new LikeDislikeBoat();
                like.userid = userId;
                like.isLike = status;
                like.boatId = boatId;
                if (status)
                {
                    if (boat.likeCount == null) // if no one has done like or dislike and first time any one doing like and dislike then assigning 1 and                                                                                0
                    {
                        boat.likeCount    = boat.likeCount < 1 ? 1 : boat.likeCount;
                        boat.disLikeCount = boat.disLikeCount < 0 ? 1 : boat.disLikeCount;
                    }
                    else
                    {
                        boat.likeCount = boat.likeCount + 1;
                    }
                }
                else
                {
                    if (boat.disLikeCount == null)
                    {
                        boat.disLikeCount = boat.disLikeCount < 1 ? 1 : boat.disLikeCount;
                        boat.likeCount    = boat.likeCount < 1 ? 1 : boat.likeCount;
                    }
                    else
                    {
                        boat.disLikeCount = boat.disLikeCount + 1;
                    }
                }
                db.LikeDislikeBoat.Add(like);
            }
            else
            {
                toggle = true;
            }
            if (toggle)
            {
                like.userid = userId;
                like.isLike = status;
                like.boatId = boatId;
                if (status)
                {
                    // if user has click like button then need to increase +1 in like and -1 in Dislike
                    boat.likeCount = boat.likeCount + 1;
                    if (boat.disLikeCount == 0 || boat.disLikeCount < 0)
                    {
                        boat.disLikeCount = 0;
                    }
                    else
                    {
                        boat.disLikeCount = boat.disLikeCount - 1;
                    }
                }
                else
                {
                    // if user has click dislike then need to increase +1 in dislike and -1 in like
                    boat.disLikeCount = boat.disLikeCount + 1;
                    if (boat.likeCount == 0 || boat.likeCount < 0)
                    {
                        boat.likeCount = 0;
                    }
                    else
                    {
                        boat.likeCount = boat.likeCount - 1;
                    }
                }
            }
            db.SaveChanges();
            return(boat.likeCount + "/" + boat.disLikeCount);
        }
Esempio n. 15
0
        // [Route("api/BoatApi/{boatId:int}")]


        //[ActionName("likeboat")]
        public string Post(LikeDislikeModel likeDislikeModel)
        {
            //if (!SessionManager.userIsLoggedIn())
            //    return new HttpStatusCodeResult(403).ToString() ;
            var             boat   = db.Boat.FirstOrDefault(x => x.id == likeDislikeModel.boatId);
            var             toggle = false;
            LikeDislikeBoat like   = db.LikeDislikeBoat.FirstOrDefault(x => x.boatId == likeDislikeModel.boatId && x.userid == likeDislikeModel.userId);

            // here we are checking whether user have done like or dislike
            if (like == null)
            {
                like        = new LikeDislikeBoat();
                like.userid = likeDislikeModel.userId;
                like.isLike = likeDislikeModel.status;
                like.boatId = likeDislikeModel.boatId;
                if (likeDislikeModel.status)
                {
                    if (boat.likeCount == null) // if no one has done like or dislike and first time any one doing like and dislike then assigning 1 and                                                                                0
                    {
                        boat.likeCount    = boat.likeCount < 1 ? 1 : boat.likeCount;
                        boat.disLikeCount = boat.disLikeCount < 0 ? 1 : boat.disLikeCount;
                    }
                    else
                    {
                        boat.likeCount = boat.likeCount + 1;
                    }
                }
                else
                {
                    if (boat.disLikeCount == null)
                    {
                        boat.disLikeCount = boat.disLikeCount < 1 ? 1 : boat.disLikeCount;
                        boat.likeCount    = boat.likeCount < 1 ? 1 : boat.likeCount;
                    }
                    else
                    {
                        boat.disLikeCount = boat.disLikeCount + 1;
                    }
                }
                db.LikeDislikeBoat.Add(like);
            }
            else
            {
                toggle = true;
            }
            if (toggle)
            {
                like.userid = likeDislikeModel.userId;
                like.isLike = likeDislikeModel.status;
                like.boatId = likeDislikeModel.boatId;
                if (likeDislikeModel.status)
                {
                    // if user has click like button then need to increase +1 in like and -1 in Dislike
                    boat.likeCount = boat.likeCount + 1;
                    if (boat.disLikeCount == 0 || boat.disLikeCount < 0)
                    {
                        boat.disLikeCount = 0;
                    }
                    else
                    {
                        boat.disLikeCount = boat.disLikeCount - 1;
                    }
                }
                else
                {
                    // if user has click dislike then need to increase +1 in dislike and -1 in like
                    boat.disLikeCount = boat.disLikeCount + 1;
                    if (boat.likeCount == 0 || boat.likeCount < 0)
                    {
                        boat.likeCount = 0;
                    }
                    else
                    {
                        boat.likeCount = boat.likeCount - 1;
                    }
                }
            }
            db.SaveChanges();
            return(boat.likeCount + "/" + boat.disLikeCount);
        }
Esempio n. 16
0
        public void Initialize()
        {
            var mockDb = new MockDatabase();

            #region Users
            var u1 = new User()
            {
                Id       = "1",
                Email    = "*****@*****.**",
                UserName = "******",
                Name     = "Darri",
                Birthday = new DateTime(2000, 1, 1),
                Work     = "HR",
                School   = "HR",
                Gender   = "Male",
                Address  = "add1",
                Privacy  = 1
            };
            mockDb.Users.Add(u1);

            var u2 = new User()
            {
                Id       = "2",
                Email    = "*****@*****.**",
                UserName = "******",
                Name     = "Jan",
                Birthday = DateTime.Today,
                Work     = "HI",
                School   = "HI",
                Gender   = "Male",
                Address  = "add2",
                Privacy  = 1
            };
            mockDb.Users.Add(u2);

            var u3 = new User()
            {
                Id       = "3",
                Email    = "*****@*****.**",
                UserName = "******",
                Name     = "Logi",
                Birthday = new DateTime(2002, 1, 1),
                Work     = "HA",
                School   = "HA",
                Gender   = "Female",
                Address  = "add3",
                Privacy  = 1
            };
            mockDb.Users.Add(u3);

            var u4 = new User()
            {
                Id       = "4",
                Email    = "*****@*****.**",
                UserName = "******",
                Name     = "Davíð",
                Birthday = new DateTime(2003, 1, 1),
                Work     = "FG",
                School   = "FG",
                Gender   = "Female",
                Address  = "add4",
                Privacy  = 1
            };
            mockDb.Users.Add(u4);

            var u5 = new User()
            {
                Id       = "5",
                Email    = "*****@*****.**",
                UserName = "******",
                Name     = "Ingþór",
                Birthday = DateTime.Today,
                Work     = "FG",
                School   = "FG",
                Gender   = "Female",
                Address  = "add5",
                Privacy  = 1
            };

            mockDb.Users.Add(u5);
            #endregion

            #region Posts
            var p1 = new Post()
            {
                PostId  = 1,
                Text    = "someText 1",
                UserId  = "1",
                Date    = new DateTime(2000, 1, 1),
                GroupId = null
            };
            mockDb.Posts.Add(p1);

            var p2 = new Post()
            {
                PostId  = 2,
                Text    = "someText 2",
                UserId  = "2",
                Date    = new DateTime(2001, 1, 1),
                GroupId = null
            };
            mockDb.Posts.Add(p2);

            var p3 = new Post()
            {
                PostId  = 3,
                Text    = "someText 3",
                UserId  = "4",
                Date    = new DateTime(2002, 1, 1),
                GroupId = null
            };
            mockDb.Posts.Add(p3);

            var p4 = new Post()
            {
                PostId  = 4,
                Text    = "someText 4",
                UserId  = "1",
                Date    = new DateTime(2003, 1, 1),
                GroupId = null
            };
            mockDb.Posts.Add(p4);

            var p5 = new Post()
            {
                PostId  = 5,
                Text    = "someText 5",
                UserId  = "3",
                Date    = new DateTime(2004, 1, 1),
                GroupId = null
            };
            mockDb.Posts.Add(p5);

            var p6 = new Post()
            {
                PostId  = 6,
                Text    = "someText 6",
                UserId  = "2",
                Date    = new DateTime(2005, 1, 1),
                GroupId = null
            };
            mockDb.Posts.Add(p6);
            #endregion

            #region Photos
            var ph1 = new Photo()
            {
                PhotoId               = 1,
                PhotoPath             = "bla1",
                UserId                = "1",
                Date                  = new DateTime(2000, 1, 1),
                IsProfilePhoto        = true,
                IsCurrentProfilePhoto = true,
            };
            mockDb.Photos.Add(ph1);

            var ph2 = new Photo()
            {
                PhotoId               = 2,
                PhotoPath             = "bla2",
                UserId                = "1",
                Date                  = new DateTime(2001, 1, 1),
                IsProfilePhoto        = true,
                IsCurrentProfilePhoto = false
            };
            mockDb.Photos.Add(ph2);

            var ph3 = new Photo()
            {
                PhotoId             = 3,
                PhotoPath           = "bla3",
                UserId              = "2",
                Date                = new DateTime(2002, 1, 1),
                IsProfilePhoto      = false,
                IsCoverPhoto        = true,
                IsCurrentCoverPhoto = true
            };
            mockDb.Photos.Add(ph3);

            var ph4 = new Photo()
            {
                PhotoId        = 4,
                PhotoPath      = "bla4",
                UserId         = "4",
                Date           = new DateTime(2003, 1, 1),
                IsProfilePhoto = false,
                IsCoverPhoto   = true
            };
            mockDb.Photos.Add(ph4);
            #endregion

            #region Notifications
            var n1 = new Notification()
            {
                NotificationId = 1,
                FriendUserId   = "2",
                UserId         = "1",
                Date           = new DateTime(2000, 1, 1)
            };
            mockDb.Notifications.Add(n1);

            var n2 = new Notification()
            {
                NotificationId = 2,
                FriendUserId   = "2",
                UserId         = "4",
                Date           = new DateTime(2001, 1, 1)
            };
            mockDb.Notifications.Add(n2);

            var n3 = new Notification()
            {
                NotificationId = 3,
                FriendUserId   = "3",
                UserId         = "1",
                Date           = new DateTime(2002, 1, 1)
            };
            mockDb.Notifications.Add(n3);
            #endregion

            #region Members
            var m1 = new Member()
            {
                UserId  = "1",
                GroupId = 1
            };
            mockDb.Members.Add(m1);

            var m2 = new Member()
            {
                UserId  = "1",
                GroupId = 2
            };
            mockDb.Members.Add(m2);

            var m3 = new Member()
            {
                UserId  = "1",
                GroupId = 3
            };
            mockDb.Members.Add(m3);

            var m4 = new Member()
            {
                UserId  = "2",
                GroupId = 1
            };
            mockDb.Members.Add(m4);

            var m5 = new Member()
            {
                UserId  = "2",
                GroupId = 3
            };
            mockDb.Members.Add(m5);

            var m6 = new Member()
            {
                UserId  = "3",
                GroupId = 2
            };
            mockDb.Members.Add(m6);

            var m7 = new Member()
            {
                UserId  = "4",
                GroupId = 3
            };
            mockDb.Members.Add(m7);

            #endregion

            #region LikesDislikes
            var ld1 = new LikeDislike()
            {
                PostId  = 1,
                UserId  = "1",
                Like    = true,
                Dislike = false
            };
            mockDb.LikesDislikes.Add(ld1);

            var ld2 = new LikeDislike()
            {
                PostId  = 1,
                UserId  = "2",
                Like    = false,
                Dislike = true
            };
            mockDb.LikesDislikes.Add(ld2);

            var ld3 = new LikeDislike()
            {
                PostId  = 2,
                UserId  = "1",
                Like    = true,
                Dislike = false
            };
            mockDb.LikesDislikes.Add(ld3);

            var ld4 = new LikeDislike()
            {
                PostId  = 3,
                UserId  = "2",
                Like    = false,
                Dislike = true
            };
            mockDb.LikesDislikes.Add(ld4);

            var ld5 = new LikeDislike()
            {
                PostId  = 3,
                UserId  = "3",
                Like    = true,
                Dislike = false
            };
            mockDb.LikesDislikes.Add(ld5);

            var ld6 = new LikeDislike()
            {
                PostId  = 4,
                UserId  = "4",
                Like    = true,
                Dislike = false
            };
            mockDb.LikesDislikes.Add(ld6);

            var ld7 = new LikeDislike()
            {
                PostId  = 4,
                UserId  = "1",
                Like    = true,
                Dislike = false
            };
            mockDb.LikesDislikes.Add(ld7);

            var ld8 = new LikeDislike()
            {
                PostId  = 4,
                UserId  = "2",
                Like    = false,
                Dislike = true
            };
            mockDb.LikesDislikes.Add(ld8);
            #endregion

            #region Groups
            var g1 = new Group()
            {
                GroupId = 1,
                Name    = "Group1"
            };
            mockDb.Groups.Add(g1);

            var g2 = new Group()
            {
                GroupId = 2,
                Name    = "Group2"
            };
            mockDb.Groups.Add(g2);

            var g3 = new Group()
            {
                GroupId = 3,
                Name    = "Group3"
            };
            mockDb.Groups.Add(g3);
            #endregion

            #region Friends
            var f1 = new Friend()
            {
                UserId       = "1",
                FriendUserId = "2",
                UserConsidersFriendAsBestFriend  = true,
                UserConsidersFriendAsFamily      = true,
                FriendConsidersUsersAsBestFriend = true,
                FriendConsidersUsersAsFamily     = true
            };
            mockDb.Friends.Add(f1);

            var f2 = new Friend()
            {
                UserId       = "2",
                FriendUserId = "3",
                UserConsidersFriendAsBestFriend = false,
                UserConsidersFriendAsFamily     = true
            };
            mockDb.Friends.Add(f2);

            var f3 = new Friend()
            {
                UserId       = "3",
                FriendUserId = "1",
                UserConsidersFriendAsBestFriend = false,
                UserConsidersFriendAsFamily     = false
            };
            mockDb.Friends.Add(f3);

            var f4 = new Friend()
            {
                UserId       = "3",
                FriendUserId = "4",
                UserConsidersFriendAsBestFriend = true,
                UserConsidersFriendAsFamily     = false
            };
            mockDb.Friends.Add(f4);

            var f5 = new Friend()
            {
                UserId       = "1",
                FriendUserId = "4",
                UserConsidersFriendAsBestFriend = false,
                UserConsidersFriendAsFamily     = false
            };
            mockDb.Friends.Add(f5);

            var f6 = new Friend()
            {
                UserId       = "5",
                FriendUserId = "2",
                UserConsidersFriendAsBestFriend  = false,
                UserConsidersFriendAsFamily      = false,
                FriendConsidersUsersAsBestFriend = false,
                FriendConsidersUsersAsFamily     = false
            };
            mockDb.Friends.Add(f6);
            #endregion

            #region Comments
            var c1 = new Comment()
            {
                CommentId = 1,
                UserId    = "1",
                PostId    = 1,
                Text      = "bla 1",
                Date      = new DateTime(2000, 11, 11)
            };
            mockDb.Comments.Add(c1);

            var c2 = new Comment()
            {
                CommentId = 2,
                UserId    = "1",
                PostId    = 1,
                Text      = "bla 2",
                Date      = new DateTime(2001, 11, 11)
            };
            mockDb.Comments.Add(c2);

            var c3 = new Comment()
            {
                CommentId = 3,
                UserId    = "2",
                PostId    = 2,
                Text      = "bla 3",
                Date      = new DateTime(2002, 11, 11)
            };
            mockDb.Comments.Add(c3);

            var c4 = new Comment()
            {
                CommentId = 4,
                UserId    = "1",
                PostId    = 3,
                Text      = "bla 4",
                Date      = new DateTime(2003, 11, 11)
            };
            mockDb.Comments.Add(c4);

            var c5 = new Comment()
            {
                CommentId = 5,
                UserId    = "2",
                PostId    = 4,
                Text      = "bla 5",
                Date      = new DateTime(2004, 11, 11)
            };
            mockDb.Comments.Add(c5);

            var c6 = new Comment()
            {
                CommentId = 6,
                UserId    = "3",
                PostId    = 6,
                Text      = "bla 6",
                Date      = new DateTime(2005, 11, 11)
            };
            mockDb.Comments.Add(c6);

            var c7 = new Comment()
            {
                CommentId = 7,
                UserId    = "4",
                PostId    = 6,
                Text      = "bla 7",
                Date      = new DateTime(2006, 11, 11)
            };
            mockDb.Comments.Add(c7);

            var c8 = new Comment()
            {
                CommentId = 8,
                UserId    = "4",
                PostId    = 4,
                Text      = "bla 8",
                Date      = new DateTime(2007, 11, 11)
            };
            mockDb.Comments.Add(c8);
            #endregion

            service = new UserService(mockDb);
        }
Esempio n. 17
0
        public void Initialize()
        {
            var mockDb = new MockDatabase();

            #region LikesDislikes
            var ld1 = new LikeDislike()
            {
                PostId  = 1,
                UserId  = "1",
                Like    = true,
                Dislike = false
            };
            mockDb.LikesDislikes.Add(ld1);

            var ld2 = new LikeDislike()
            {
                PostId  = 1,
                UserId  = "2",
                Like    = false,
                Dislike = true
            };
            mockDb.LikesDislikes.Add(ld2);

            var ld3 = new LikeDislike()
            {
                PostId  = 2,
                UserId  = "1",
                Like    = true,
                Dislike = false
            };
            mockDb.LikesDislikes.Add(ld3);

            var ld4 = new LikeDislike()
            {
                PostId  = 3,
                UserId  = "2",
                Like    = false,
                Dislike = true
            };
            mockDb.LikesDislikes.Add(ld4);

            var ld5 = new LikeDislike()
            {
                PostId  = 3,
                UserId  = "3",
                Like    = true,
                Dislike = false
            };
            mockDb.LikesDislikes.Add(ld5);

            var ld6 = new LikeDislike()
            {
                PostId  = 4,
                UserId  = "4",
                Like    = true,
                Dislike = false
            };
            mockDb.LikesDislikes.Add(ld6);

            var ld7 = new LikeDislike()
            {
                PostId  = 4,
                UserId  = "1",
                Like    = true,
                Dislike = false
            };
            mockDb.LikesDislikes.Add(ld7);

            var ld8 = new LikeDislike()
            {
                PostId  = 4,
                UserId  = "2",
                Like    = false,
                Dislike = true
            };
            mockDb.LikesDislikes.Add(ld8);
            #endregion

            service = new LikeDislikeService(mockDb);
        }