public IActionResult Delete(string id) { Circle Circle = _circleService.Get(id); if (Circle == null) { return(NotFound()); } _circleService.Remove(Circle.Id); return(Ok(Circle.Id)); }
public IActionResult Delete(string id) { var circle = _circleService.Get(id); if (circle == null) { return(NotFound()); } _circleService.Remove(id); return(NoContent()); }
public ActionResult Delete(string id, IFormCollection collection) { try { var circle = _circleService.Get(id); if (circle == null) { return(NotFound()); } _circleService.Remove(circle.CircleId); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public IActionResult Delete(string id) { _circleService.Remove(id); return(RedirectToAction("Index")); }
private void SeedData(IDabHandIn3DatabaseSettings settings) { UserService userService = new UserService(settings); CircleService circleService = new CircleService(settings); PostService postService = new PostService(settings); // Seeding Users List <User> users = userService.Get(); if (users != null) { foreach (var user in users) { userService.Remove(user); } } List <User> usersToInsert = new List <User>() { new User() { UserName = "******", Age = 21, Email = "*****@*****.**", Gender = "Male", BlockedUsers = new List <string>(), Following = new List <string>() }, new User() { UserName = "******", Age = 21, Email = "*****@*****.**", Gender = "Male", BlockedUsers = new List <string>(), Following = new List <string>() }, new User() { UserName = "******", Age = 22, Email = "*****@*****.**", Gender = "Male", BlockedUsers = new List <string>(), Following = new List <string>() }, new User() { UserName = "******", Age = 22, Email = "*****@*****.**", Gender = "Male", BlockedUsers = new List <string>(), Following = new List <string>() } }; foreach (var user in usersToInsert) { userService.Create(user); } // Roman follows Rosendal usersToInsert[1].Following = new List <string>() { usersToInsert[0].Id }; userService.Update(usersToInsert[1].Id, usersToInsert[1]); // Seeding Circles List <Circle> circles = circleService.Get(); if (circles != null) { foreach (var circle in circles) { circleService.Remove(circle); } } List <Circle> circlesToInsert = new List <Circle>() { new Circle() { Admin = usersToInsert[0], Public = true, CircleName = "Rosendals Circle", PostIds = new List <string>(), UserIds = new List <string>() { usersToInsert[0].Id, usersToInsert[1].Id } }, new Circle() { Admin = usersToInsert[2], Public = false, CircleName = "Bommys Circle", PostIds = new List <string>(), UserIds = new List <string>() { usersToInsert[2].Id, usersToInsert[3].Id } } }; foreach (var circle in circlesToInsert) { circleService.Create(circle); } // Seeding Posts List <Post> posts = postService.Get(); if (posts != null) { foreach (var post in posts) { postService.Remove(post); } } List <Post> postsToInsert = new List <Post>() { new Post() { Author = usersToInsert[0], Content = new Content() { Text = "Now this is content boys", Image = null }, Comments = new List <Comment>() { new Comment() { Author = usersToInsert[1], Content = "This is not content boys", CreationTime = DateTime.Now } }, CreationTime = DateTime.Now.AddMinutes(-1) }, new Post() { Author = usersToInsert[0], Content = new Content() { Text = "So bored today, lol", Image = null }, Comments = new List <Comment>() { new Comment() { Author = usersToInsert[2], Content = "Roflcopter", CreationTime = DateTime.Now } }, CreationTime = DateTime.Now.AddMinutes(-2) } }; foreach (var post in postsToInsert) { postService.Create(post, circlesToInsert[0].Id); } }