Example #1
0
        public async Task <JsonResult> Unsubscribe(int noticeboardId)
        {
            try
            {
                var board = await db.GetAsync(noticeboardId);

                RelationshipManager rm = new RelationshipManager();
                int result             = await rm.DeleteAsync(
                    new UserNoticeBoardFollow
                {
                    NoticeBoardId = noticeboardId,
                    UserId        = (await User.Identity.GetApplicationUserAsync()).Id
                }
                    );

                if (result > 0)
                {
                    return(Json(JsonViewModel.Success, JsonRequestBehavior.DenyGet));
                }
            }
            catch
            {
                return(Json(JsonViewModel.Error, JsonRequestBehavior.DenyGet));
            }
            return(Json(JsonViewModel.Error, JsonRequestBehavior.DenyGet));
        }
Example #2
0
        public async Task <IHttpActionResult> Unsubscribe(int id)
        {
            try
            {
                using (NoticeBoardManager db = new NoticeBoardManager())
                {
                    var board = await db.GetAsync(id);

                    RelationshipManager rm = new RelationshipManager();
                    int result             = await rm.DeleteAsync(
                        new UserNoticeBoardFollow
                    {
                        NoticeBoardId = id,
                        UserId        = (await User.Identity.GetApplicationUserAsync()).Id
                    }
                        );

                    if (result > 0)
                    {
                        return(Ok(JsonViewModel.Success));
                    }
                }
            }
            catch
            {
                return(InternalServerError());
            }
            return(NotFound());
        }