public async Task <JsonResult> Subscribe(int noticeboardId) { var board = await db.GetAsync(noticeboardId); RelationshipManager rm = new RelationshipManager(); int result = await rm.AddAsync( new UserNoticeBoardFollow { NoticeBoardId = noticeboardId, UserId = (await User.Identity.GetApplicationUserAsync()).Id } ); if (result > 0) { return(Json(JsonViewModel.Success, JsonRequestBehavior.DenyGet)); } return(Json(JsonViewModel.Error, JsonRequestBehavior.DenyGet)); }
public async Task <IHttpActionResult> Subscribe(int id) { using (NoticeBoardManager db = new NoticeBoardManager()) { var board = await db.GetAsync(id); RelationshipManager rm = new RelationshipManager(); int result = await rm.AddAsync( new UserNoticeBoardFollow { NoticeBoardId = id, UserId = (await User.Identity.GetApplicationUserAsync()).Id } ); if (result > 0) { return(Ok(JsonViewModel.Success)); } // shouldn't reach here unless a concurrency issue occurs return(InternalServerError()); } }