public JsonResult Logout() { ResponseMessage msg = new ResponseMessage("Logout", RAction.LOGOUT, RStatus.FAIL, "Cannot logout."); try { frontendService.Logout(); msg.SetStatusAndMessage(RStatus.SUCCESS, "Logged Out."); msg.ReturnedPath = Url.RouteUrl("Root"); } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult Post(int uid, string inputText) { ResponseMessage msg = new ResponseMessage("UserPostTweet", RAction.ADD, RStatus.FAIL, "<p>Incomplete post.</p>"); try { frontendService.PostUserTweet(uid, inputText); msg.SetStatusAndMessage(RStatus.SUCCESS, "<p>Posted.</p>"); } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult CancelUpload() { ResponseMessage msg = new ResponseMessage("ImageUploader", RAction.REMOVE, RStatus.FAIL, "Error when processing your request."); try { frontendService.RemoveImagesFromDisk(this.Session); msg.SetStatusAndMessage(RStatus.SUCCESS, "Canceled."); } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult Remove(int albumId) { ResponseMessage msg = new ResponseMessage("PhotoAlbum", RAction.REMOVE, RStatus.FAIL, "An error occurs when removing this album."); try { frontendService.RemoveAlbum(albumId); msg.SetStatusAndMessage(RStatus.SUCCESS, "Removed successfully."); msg.ReturnedPath = Url.RouteUrl("PhotoAlbumList", new { uid = Globals.GetDisplayId(sessionManager.GetUser()) }); } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult UnlikeForFeed(long feedId) { ResponseMessage msg = new ResponseMessage("LikeForFeed", RAction.ADD, RStatus.FAIL, "Cannot process for this like. Please try again."); try { Domain.User myUser = sessionManager.GetUser(); frontendService.UnlikeForFeed(feedId, myUser.UserId); msg.SetStatusAndMessage(RStatus.SUCCESS, "Unliked."); } catch (Exception e) { msg.Message = e.Message; } return Json(msg, JsonRequestBehavior.AllowGet); }
public JsonResult Remove(string typeId, int itemId, int commentId) { ResponseMessage msg = new ResponseMessage("Comment", RAction.REMOVE, RStatus.FAIL, "Cannot delete this item because it's not exists or you do not have permission."); try { if (frontendService.RemoveComment(typeId, itemId, commentId) > 0) { msg.SetStatusAndMessage(RStatus.SUCCESS, "Removed."); } } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult Remove(long feedId) { ResponseMessage msg = new ResponseMessage("Feed", RAction.REMOVE, RStatus.FAIL, "An error occurs when removing this feed."); try { User user = sessionManager.GetUser(); if (frontendService.RemoveFeed(feedId, user.UserId)) { msg.SetStatusAndMessage(RStatus.SUCCESS, "Removed."); } } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult Remove(int albumId, int photoId) { ResponseMessage msg = new ResponseMessage("Photo", RAction.REMOVE, RStatus.FAIL, "An error occurred when deleting this photo. Or you do not have permission.s"); try { int totalRemoved = frontendService.RemovePhoto(albumId, photoId); if (totalRemoved > 0) { frontendService.RemoveFeed_OnPhotoAlbumEmpty(albumId); msg.SetStatusAndMessage(RStatus.SUCCESS, "Removed."); } } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult EditInfoSave(string username, string fullName, string email, byte gender, short birthday_year, byte birthday_month, byte birthday_day, string countryiso) { ResponseMessage msg = new ResponseMessage("ProfileEditInfo", RAction.EDIT, RStatus.FAIL, "Cannot update your profile. Please recheck your info."); try { User user = frontendService.UpdateProfileInfo(username, fullName, email, gender, (birthday_year + "/" + birthday_month + "/" + birthday_day), countryiso); msg.SetStatusAndMessage(RStatus.SUCCESS, "Your profile have updated."); msg.ReturnedPath = Url.RouteUrl("ProfileInfo", new { uid = Globals.GetDisplayId(user) }); } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult Login(string nsnId, string nsnPasswd) { ResponseMessage msg = new ResponseMessage("Login", RAction.LOGIN, RStatus.FAIL, @"<p class='nsn-popup-msg ui-state-error'>Incorrect ID or password. Access denied.</p> <p>The username you entered does not belong to any account.</p> <p>You can login using any email or username associated with your account. Make sure that it is typed correctly.</p>"); try { Domain.User user = frontendService.Login(nsnId, nsnPasswd); if (user != null) { msg.SetStatusAndMessage(RStatus.SUCCESS, "Authenticated!"); } } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult Accept(int requestId) { ResponseMessage msg = new ResponseMessage("Friend", RAction.ADD, RStatus.FAIL, "Cannot accept this friend request."); try { int timestamp = DateTimeUtils.UnixTimestamp; // Chấp nhận làm bạn Friend friend = frontendService.AcceptFriendRequest(requestId, timestamp); // Giảm số FriendRequest trong bảng UserCount frontendService.IncreaseCountOfFriendRequest(sessionManager.GetUser().UserId, -1); // Thông báo lên Feed feedRepo.Add(NSNType.FRIEND, friend.FriendId, friend.User.UserId, friend.FriendUser.UserId, timestamp); msg.SetStatusAndMessage(RStatus.SUCCESS, "Accepted."); } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult SaveUploadedPhotos(int albumId, byte privacy = 0) { ResponseMessage msg = new ResponseMessage("Photo", RAction.ADD, RStatus.FAIL, "Error when uploading your photos. Please try again."); try { int timestamp = DateTimeUtils.UnixTimestamp; // Add more photo images frontendService.AddPhotosToAlbum(this.Session, albumId, timestamp, privacy); // Remove photo images from session frontendService.RemoveImagesFromSession(this.Session); // Insert to feed feedRepo.Add(NSNType.PHOTO, albumId, sessionManager.GetUser().UserId, 0, timestamp); // Returns msg.SetStatusAndMessage(RStatus.SUCCESS, String.Format("Uploaded your photos to album: <strong>{0}</strong>", "")); msg.ReturnedPath = Url.RouteUrl("PhotoAlbumAction", new { uid = Globals.GetDisplayId(sessionManager.GetUser()), albumid = albumId, action = "ListPhotos" }); } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult Register(string firstname, string lastname, byte gender, string reg_email, string reg_password, string confirm_password, short birthday_year, byte birthday_month, byte birthday_day) { ResponseMessage msg = new ResponseMessage("Register", RAction.ADD, RStatus.FAIL, @"<p>Quá trình đăng ký gặp trắc trở và đã thất bại. Ôi thê thảm quá!</p>"); try { // Add new user Domain.User user = frontendService.RegisterNewUser(firstname, lastname, gender, reg_email, reg_password, confirm_password, (birthday_year + "/" + birthday_month + "/" + birthday_day)); // Init user count pending frontendService.CreateUserCount(user); // Returns msg.SetStatusAndMessage(RStatus.SUCCESS, String.Format(@"<p>Register successfully! Welcome to New Social Network.</p> <p>Your login ID is <strong>{0}</strong>.</p>", user.Email)); } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult AddSave(int friendUserId, string message) { ResponseMessage msg = new ResponseMessage("RequestFriend", RAction.ADD, RStatus.FAIL, "Cannot process your request friend."); try { // Add new request frontendService.AddRequestFriend(friendUserId, message); // Add pending frontendService.IncreaseCountOfFriendRequest(friendUserId); // Returns msg.SetStatusAndMessage(RStatus.SUCCESS, "Request friend sent."); } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }
public JsonResult Cancel(int requestId) { ResponseMessage msg = new ResponseMessage("Friend", RAction.ADD, RStatus.FAIL, "Cannot cancel this friend request."); try { User myUser = sessionManager.GetUser(); // Hủy yêu cầu kết bạn frontendService.CancelFriendRequest(requestId, myUser.UserId); // Giảm số FriendRequest trong bảng UserCount frontendService.IncreaseCountOfFriendRequest(myUser.UserId, -1); msg.SetStatusAndMessage(RStatus.SUCCESS, "Canceled."); } catch (Exception e) { msg.Message = e.Message; } return Json(msg); }