public void Create(Comment comment, int pinId, string userId) { comment.PinId = pinId; comment.UserId = userId; comment.DateTime = DateTime.Now; var currentUser = this.FindUser(userId); var pin = this.FindPin(pinId); var newNote = new Notification() { DateTime = DateTime.Now, Message = currentUser.DisplayName + " has left a comment on your pin: " + comment.Words, UserId = pin.UserId, PinId = pin.Id, }; _repo.Add<Comment>(comment); _repo.Add<Notification>(newNote); _repo.SaveChanges(); }
public void PinIt(Pin pin, string userId, int boardId) { var newPin = new Pin { Title = pin.Title, Board = pin.Board, BoardId = pin.BoardId, Category = pin.Category, CategoryId = pin.CategoryId, ImageUrl = pin.ImageUrl, Website = pin.Website, ShortDescription = pin.ShortDescription, LongDescription = pin.LongDescription, UserId = userId, IsActive = true }; var currentUser = this.FindUser(userId); var newNote = new Notification() { DateTime = DateTime.Now, Message = currentUser.DisplayName + " has pinned your pin!", UserId = _repo.Query<Pin>().Where(p => p.Id == pin.Id).FirstOrDefault().UserId, User = pin.User, PinId = pin.Id, }; _repo.Add<Pin>(newPin); _repo.Add<Notification>(newNote); _repo.SaveChanges(); this.UpdatePinCount(boardId); }
public void Delete(int id) { if (ClaimsHelper.UserIsAdmin()) { var userId = this.FindPinUserId(id); var newNote = new Notification() { DateTime = DateTime.Now, Message = "Your pin has been removed due to inappropriate content.", UserId = userId, PinId = id }; _repo.Add<Notification>(newNote); _repo.SaveChanges(); } var pin = this.Find(id); pin.IsActive = false; var board = pin.Board; var original = this.Find(id); var originalBoardId = original.BoardId; _repo.SaveChanges(); this.UpdatePinCount(board.Id); }
public void FlagThis(int pinId, string userId) { var flag = new Flag { DateTime = DateTime.Now, UserId = userId, User = this.FindUser(userId), PinId = pinId, Pin = this.Find(pinId) }; var pinUserId = this.FindPinUserId(pinId); var newNote = new Notification() { DateTime = DateTime.Now, Message = "Your pin has been flagged for review.", UserId = pinUserId, User = this.FindUser(pinUserId), PinId = pinId }; _repo.Add<Flag>(flag); _repo.Add<Notification>(newNote); _repo.SaveChanges(); this.UpdateFlagCount(pinId); }