public string WriteWallPost(string text) { UserModel receiver = Session["UserProfile"] as UserModel; UserModel sender = Session["CurrentUser"] as UserModel; WallPostModel last = _unitOfWork.WallPosts.WriteWallPost(receiver.Id, sender.Id, text, _attachmentsWallpost); last.Id = _unitOfWork.WallPosts.GetAll().Last().Id; if (_attachmentsWallpost == null) { _attachmentsWallpost = new List <FileModel>(); } _attachmentsWallpost.Clear(); return(JsonConvert.SerializeObject(new { Id = last.Id, Content = last.Content, Likes = last.Likes.Count, Sender = last.Sender.Username, Username = last.Owner.Username, Comments = last.Comments, Files = last.Attachments.Where(f => !f.IsImage()).ToList(), Images = last.Attachments.Where(f => f.IsImage()).ToList(), IsDeletable = (sender.Id == receiver.Id) })); }
private WallPostModel MapWallPost(WallPost model) { if (model != null) { var result = new WallPostModel { Body = model.Body, CreatedDate = model.CreatedDate, Id = model.Id, ModifiedDate = model.ModifiedDate, PostedBy = model.CreatedBy, PostType = model.PostType }; if (model.UserWall != null) { result.WallOwner = new WallModel { OwnerId = model.UserWall.UserId, WallOwnerType = WallType.user }; } else if (model.GroupWall != null) { result.WallOwner = new WallModel { OwnerId = model.GroupWall.GroupId, WallOwnerType = WallType.group }; } return(result); } return(null); }
public ActionResult UpdateEntry(WallPostModel request) { wallEntryService.UpdatePost(request); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }