public ActionResult Create_Post(string userId, Post post) { _postsService.Create(post); if (post.CircleId != null) // not tested { var circle = _circleService.Get(post.CircleId); if (circle == null) { return(NotFound()); } circle.PostId.Add(post.Id); _circleService.Update(circle); } else { var user = _userService.Get(userId); if (user == null) { return(NotFound()); } user.PostId.Add(post.Id); _userService.Update(user); } return(NoContent()); }
public IActionResult Update(string id, Circle newCircle) { Circle Circle = _circleService.Get(id); if (Circle == null) { return(NotFound()); } _circleService.Update(id, newCircle); return(Ok(newCircle)); }
public IActionResult Update(string id, Circle circleIn) { var circle = _circleService.Get(id); if (circle == null) { return(NotFound()); } _circleService.Update(id, circleIn); return(NoContent()); }
public ActionResult Edit(string id, Circle circle) { try { circle.CircleId = id; _circleService.Update(id, circle); return(RedirectToAction(nameof(Index))); } catch { return(View(circle)); } }
public IActionResult Update(string id, [FromBody] User user) { var circle = _circleService.Get(id); if (circle == null) { return(NotFound()); } _circleService.Update(id, user); //return NoContent(); return(Ok()); }
public ActionResult CreateToCirlce(PostViewModel model) { if (ModelState.IsValid) { model.Post.TimeCreated = DateTime.Now; var createdPost = postService.Add(model.Post); var user = userService.Get(model.Post.Id); if (user != null) { var circles = circleService.Get(); Circle circle = new Circle(); foreach (var c in circles) { if (c.Name == model.Circle.Name) { circle = c; } } circle.PostIds.ToList().Add(createdPost.Id); circleService.Update(circle, circle.Id); if (string.IsNullOrEmpty(model.Circle.Name)) { user.PostIds.ToList().Add(createdPost.Id); userService.Update(user, user.Id); } } else { return(NotFound()); } return(RedirectToAction("profile", "Session", new { id = userService.Get(model.Post.Id).Id })); } return(View()); }
public ActionResult AddUser(string userId, string circleName) { var user = userService.Get(userId); var circles = circleService.Get(); var circle = new Circle(); foreach (var c in circles) { if (c.Name == circleName) { circle = c; } } user.CircleIds.ToList().Add(circle.Id); userService.Update(user, user.Id); circle.UserIds.ToList().Add(user.Id); circleService.Update(circle, circle.Id); return(RedirectToAction("Profile", "Session", new { id = user.Id })); }
public ActionResult Create(Circle circle) { var loggedInUserId = _circleService.GetLoggedInUserId(); circle.OwnerId = loggedInUserId; var circleId = _circleService.Create(circle); var wall = new Wall() { owner = circle.Name, Followers = new List <follower>() { new follower() { followerID = loggedInUserId, followerName = _userService.Get(loggedInUserId).Name } }, BlackList = new List <blacklistedUser>(), ownerID = circleId, type = "Circle", postIDs = new List <string>(), }; var newWall = _wallService.Create(wall); //add circle.wallId after creating wall circle.WallId = newWall.ID; circle.Id = circleId; _circleService.Update(circle.Id, circle); return(RedirectToAction("GetWall", "Wall", new { id = circleId, type = "Circle" })); }
public void Update(string Id, Circle circleIn) { var circle = _circleService.Get(Id); _circleService.Update(Id, circleIn); }