public HttpResponseMessage DeleteCurrentByHandle(string handle) { BaseResponse response = null; try { IdentityUser user = _userService.GetCurrentUser(); if (user != null) { FollowerRequest requestData = new FollowerRequest(); FollowNewsletter nwsInfo = new FollowNewsletter(); Account followedLG = _accountSrv.GetAccountByHandle(handle); requestData.FollowerID = user.Id; requestData.ProfileUID = followedLG.UserId; //requestData.FollowNewsletter = (delete.Contains("newsletter")) ? true : false; nwsInfo.Email = user.Email; nwsInfo.Handle = handle; _followerSevice.Delete(requestData, nwsInfo); response = new SuccessResponse(); return(Request.CreateResponse(HttpStatusCode.OK, response)); } else { response = new ErrorResponse("User is not logged in"); return(Request.CreateResponse(HttpStatusCode.InternalServerError, response)); } } catch (Exception ex) { response = new ErrorResponse(ex.Message); return(Request.CreateResponse(HttpStatusCode.InternalServerError, response)); } }
public JsonResult ChangeToFollower(int id) { int fromAccountID = (int)Session["userID"]; Follower follower = _followerService.GetFollower(fromAccountID, id); if (follower == null) { _followerService.Add(new Follower { FollowDate = DateTime.Now, FromAccountID = fromAccountID, ToAccountID = id }); return(Json(Mapper.Map <List <DiaryForProfileDto> >(_diaryService.GetDiariesForFollower(id)), JsonRequestBehavior.AllowGet)); } else { _followerService.Delete(follower); return(Json(Mapper.Map <List <DiaryForProfileDto> >(_diaryService.GetDiariesForPublic(id)), JsonRequestBehavior.AllowGet)); } }