public async Task <ActionResult <FollowModel> > DeleteFollow(long userId, long followerId) { try { var followToBeDeleted = await _followService.GetFollowById(userId, followerId); if (followToBeDeleted == null) { return(NotFound()); } var postModel = _mapper.Map <Follow, FollowModel>(followToBeDeleted); await _followService.DeleteFollow(followToBeDeleted); return(Ok(postModel)); } catch (DBException e) { return(BadRequest(e.Message)); } catch (Exception e) { return(BadRequest("Internal error.")); } }
public async Task <IActionResult> Delete(string profileId, string followerId) { if (ModelState.IsValid) { var response = await _followService.DeleteFollow(new Guid(profileId), new Guid(followerId)); return(response.Success ? new OkObjectResult(response) : StatusCode(500)); } return(StatusCode(400)); }
public ActionResult FollowProduct(Follow vm) { if (followService.isExistFollow(vm.ProductId, vm.UserId) == false) { vm.IsChecked = true; followService.AddFollow(vm); } else { var model = followService.FindFollow(vm.ProductId, vm.UserId); followService.DeleteFollow(model); } return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> Delete(int id) { await _followService.DeleteFollow(id); return(Ok(new { message = "Follow deleted successfully" })); }