public async Task <ActionResult> DeleteCommunity(DeleteCommunity community)
        {
            CommunityService service = CommunityService.GetInstance();
            var res = await service.GetByIdAsync(community.Id);

            if (res.Success)
            {
                if (res.Result.name == community.Name)
                {
                    var deleted = await service.DeleteCommunity(new CreateCommunity { Id = community.Id, UserId = User.Identity.GetUserId() });

                    if (deleted.Success)
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    return(PartialView("_DeleteCommunity", community));
                }
            }

            return(View());
        }
Example #2
0
        public void GetCommunityById()
        {
            var res = communityService.GetByIdAsync(1).Result;

            Assert.IsTrue(res.Success);
        }