public ImageComment GetImageComment(ISession session) { ImageComment ei = (Id != 0) ? (ImageComment)session.Load(typeof(ImageComment), Id) : new ImageComment(); ei.Comment = (Comment)session.Load(typeof(Comment), CommentId); ei.Image = (Image)session.Load(typeof(Image), ImageId); return(ei); }
public async Task <PartialViewResult> PostImageComment(ImageComment comment, IFormCollection collection) { long?imageId = Convert.ToInt64(collection["ImageId"]); var image = _databaseConnection.Images.Find(imageId); var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId")); comment.DateCreated = DateTime.Now; comment.AppUserId = signedInUserId; comment.ImageId = imageId; comment.Comment = collection["Comment"].ToString(); comment.CreatedBy = signedInUserId; comment.LastModifiedBy = signedInUserId; comment.DateLastModified = DateTime.Now; _databaseConnection.ImageComments.Add(comment); _databaseConnection.SaveChanges(); //send notification for owner of photo if (image.AppUserId != comment.CreatedBy) { var notification = new PushNotification { AppUserId = image.AppUserId, CreatedBy = signedInUserId, LastModifiedBy = signedInUserId, DateLastModified = DateTime.Now, DateCreated = DateTime.Now, Category = SystemNotificationCategory.Comment.ToString(), Read = false, ControllerId = imageId }; var singleOrDefault = _users.SingleOrDefault(n => n.AppUserId == comment.CreatedBy); if (singleOrDefault != null) { notification.Message = singleOrDefault.Name + " Commented on your Image"; } await new AppUserFactory().SavePushNotification(new AppConfig().SavePushNotifications, notification); } var newComments = _databaseConnection.ImageComments.Where(n => n.ImageId == imageId).ToList(); var appTransport = new AppTransport { ImageComments = newComments, AppUsers = _users, Images = _databaseConnection.Images.Include(n => n.ImageCategory) .Include(n => n.ImageComments).Include(n => n.ImageTags) .Include(n => n.Location).Include(n => n.ImageSubCategory).ToList(), ImageActions = _databaseConnection.ImageActions.ToList(), Image = image, AppUser = _users.SingleOrDefault(n => n.AppUserId == signedInUserId) }; return(PartialView("Partials/_ImageComment", appTransport)); }
public bool DeleteImageComment(ImageComment imageComment) { try { _dbContext.ImageComments.Remove(imageComment); _dbContext.SaveChangesAsync(); return(true); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task AddImageComment(AddImageCommentViewModel input) { var imageComment = new ImageComment { PhotographyAddictedUserId = input.PhotographyAddictedUserId, ImageId = input.ImageId, UserOpinion = input.UserOpinion, CreationDate = DateTime.UtcNow, }; await imageCommentDbSet.AddAsync(imageComment); await imageCommentDbSet.SaveChangesAsync(); }
public ImageCommentTest() { ImageTest image = new ImageTest(); AddDependentObject(image); CommentTest comment = new CommentTest(); AddDependentObject(comment); mImageComment = new ImageComment(); mImageComment.Image = image.Image; mImageComment.Comment = comment.Comment; }
public async Task AddComment(Guid imageId, string comment, double score, string phrases) { var commentTable = Configuration["CommentsTable"]; var imageComment = new ImageComment { PartitionKey = imageId.ToString(), Comment = comment, ImageId = imageId, Phrases = phrases, Score = score }; await CloudTableService.Insert(imageComment, commentTable); }
public bool CommentImage(string commentId, string imageId) { try { ImageComment imageComment = new ImageComment { CommentId = commentId, ImageId = imageId, }; _dbContext.ImageComments.Add(imageComment); _dbContext.SaveChanges(); return(true); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ImageCommentSuccessModel Add(ImageCommentModel imageCommentModel) { var imageCommentSuccessModel = new ImageCommentSuccessModel(); try { ImageComment dbNewImageComment = new ImageComment(); dbNewImageComment.Id = Guid.NewGuid().ToString(); dbNewImageComment.Posted = DateTime.Now; dbNewImageComment.ImageLinkId = imageCommentModel.ImageLinkId; dbNewImageComment.CommentText = imageCommentModel.CommentText; dbNewImageComment.CommentTitle = imageCommentModel.CommentTitle; dbNewImageComment.CalledFrom = imageCommentModel.CalledFrom; dbNewImageComment.VisitorId = imageCommentModel.VisitorId; using (var db = new OggleBoobleMySqlContext()) { db.ImageComments.Add(dbNewImageComment); db.SaveChanges(); CategoryFolder categoryFolder = db.CategoryFolders.Where(f => f.Id == imageCommentModel.FolderId).FirstOrDefault(); imageCommentSuccessModel.FolderName = categoryFolder.FolderName; Visitor visitor = db.Visitors.Where(v => v.VisitorId == imageCommentModel.VisitorId).FirstOrDefault(); if (visitor != null) { imageCommentSuccessModel.VisitorInfo = visitor.City + " " + visitor.Region + " " + visitor.Country; } RegisteredUser dbRegisteredUser = db.RegisteredUsers.Where(u => u.VisitorId == imageCommentModel.VisitorId).FirstOrDefault(); if (dbRegisteredUser != null) { imageCommentSuccessModel.UserName = dbRegisteredUser.UserName; } imageCommentSuccessModel.Success = "ok"; } } catch (Exception ex) { imageCommentSuccessModel.Success = Helpers.ErrorDetails(ex); } return(imageCommentSuccessModel); }
public string Update(ImageComment imageComment) { string success; try { imageComment.Id = Guid.NewGuid().ToString(); imageComment.Posted = DateTime.Now; using (var db = new OggleBoobleMySqlContext()) { db.ImageComments.Add(imageComment); db.SaveChanges(); success = "ok"; } } catch (Exception ex) { success = Helpers.ErrorDetails(ex); } return(success); }
public async Task <JsonResult> SaveComment([FromBody] ImageComment comment) { _databaseConnection.Add(comment); _databaseConnection.SaveChanges(); var image = _databaseConnection.Images.SingleOrDefault(n => n.ImageId == comment.ImageId); if (comment.ImageCommentId > 0) { if (image != null) { var notification = new PushNotification { AppUserId = image.AppUserId, CreatedBy = comment.CreatedBy, LastModifiedBy = comment.CreatedBy, DateLastModified = DateTime.Now, DateCreated = DateTime.Now, Category = SystemNotificationCategory.Comment.ToString(), Read = false, ControllerId = image.ImageId, ClientId = 4 }; var singleOrDefault = new AppUserFactory() .GetAllUsers(new AppConfig().FetchUsersUrl).Result .SingleOrDefault(n => n.AppUserId == image.AppUserId); if (singleOrDefault != null) { notification.Message = singleOrDefault.Name + " Commented on your Image"; } await new AppUserFactory().SavePushNotification(new AppConfig().SavePushNotifications, notification); } } return(Json(comment)); }
public GalleryComment(ImageComment imageComment) { InitializeComponent(); ImageComment = imageComment; DataContext = this; }
public void UpdateComment(int commentId, string updatedRemark) { ScopeAsync(async (c, t) => { // Arrange var commentRepo = new ImageCommentRepository(c); var updated = new ImageComment { PostedOn = DateTime.Now, Text = updatedRemark }; // Act var result = await commentRepo.UpdateSingle(commentId, updated); // Assert Assert.True(result); }); }
public void CreateComment(string remark, int userId, int imageId) { ScopeAsync(async (c, t) => { // Arrange var commentRepo = new ImageCommentRepository(c); var comment = new ImageComment { Author = new User { ID = userId }, PostedOn = DateTime.Now, Text = remark, }; // Act Func<ImageComment, Task> onCreate = com => Task.FromResult(0); var result = await commentRepo.CreateSingle(comment, onCreate); // Assert Assert.True(result.HasValue); }); }