public async Task <IActionResult> Create() { var context = CreateDomainContext(); var forumDomain = DomainProvider.GetService <EntityDomainService <Entity.Forum> >(); IEntityEditModel <Entity.Forum> forumResult; try { forumResult = await forumDomain.ExecuteAsync <IEntityEditModel <Entity.Forum> >(context, "Detail"); ViewBag.Forum = forumResult.Item; } catch (DomainServiceException ex) { if (ex.InnerException is ArgumentException) { return(StatusCode(400, ex.InnerException.Message)); } else if (ex.InnerException is EntityNotFoundException) { return(NotFound()); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >(); IEntityEditModel <Thread> threadResult = await threadDomain.ExecuteAsync <IEntityEditModel <Thread> >(context, "Create"); threadResult.Item.Forum = forumResult.Item; return(View(threadResult)); }
public Task <TResult> ExecuteAsync <TDomainService, TResult>(IDomainContext context, string method) where TDomainService : IDomainService { var domain = DomainProvider.GetService <TDomainService>(); return(domain.ExecuteAsync <TResult>(context, method)); }
public async Task <IActionResult> Index() { var context = CreateDomainContext(); var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >(); IEntityEditModel <Thread> threadResult; try { threadResult = await threadDomain.ExecuteAsync <IEntityEditModel <Thread> >(context, "Detail"); ViewBag.Thread = threadResult.Item; } catch (DomainServiceException ex) { if (ex.InnerException is ArgumentException) { return(StatusCode(400, ex.InnerException.Message)); } else if (ex.InnerException is EntityNotFoundException) { return(NotFound()); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } var postDomain = DomainProvider.GetService <EntityDomainService <Post> >(); IEntityViewModel <Post> postResult = await postDomain.ExecuteAsync <IEntityViewModel <Post> >(context, "List"); return(View(postResult)); }
public async Task <IActionResult> Create() { var context = CreateDomainContext(); var forumDomain = DomainProvider.GetService <EntityDomainService <Entity.Forum> >(); IEntityEditModel <Entity.Forum> forumResult; try { forumResult = await forumDomain.ExecuteAsync <IEntityEditModel <Entity.Forum> >(context, "Detail"); ViewBag.Forum = forumResult.Item; } catch (ArgumentException ex) { return(NotFound()); } catch (EntityNotFoundException ex) { return(NotFound()); } var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >(); IEntityEditModel <Thread> threadResult = await threadDomain.ExecuteAsync <IEntityEditModel <Thread> >(context, "Create"); threadResult.Item.Forum = forumResult.Item; return(View(threadResult)); }
public async Task <IActionResult> SignUp(string username) { if (User.Identity.IsAuthenticated) { return(StatusCode(200)); } var memberDomain = DomainProvider.GetService <MemberDomainService>(); var context = CreateDomainContext(); try { await memberDomain.ExecuteAsync(context, "SignUp"); } catch (DomainServiceException ex) { if (ex.InnerException is ArgumentException) { return(StatusCode(401, ex.InnerException.Message)); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } return(StatusCode(200)); }
public async Task <IActionResult> Index() { var context = CreateDomainContext(); var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >(); IEntityEditModel <Thread> threadResult; try { threadResult = await threadDomain.ExecuteAsync <IEntityEditModel <Thread> >(context, "Detail"); ViewBag.Thread = threadResult.Item; } catch (ArgumentException ex) { return(NotFound()); } catch (EntityNotFoundException ex) { return(NotFound()); } var postDomain = DomainProvider.GetService <EntityDomainService <Post> >(); IEntityViewModel <Post> postResult = await postDomain.ExecuteAsync <IEntityViewModel <Post> >(context, "List"); return(View(postResult)); }
public virtual async Task <IActionResult> Thread() { var context = GetThreadDomainContext(); var domain = DomainProvider.GetService <ForumDomainService>(); try { var thread = await domain.ExecuteGetThread(context); ViewBag.Thread = thread; } catch (DomainServiceException ex) { if (ex.InnerException is KeyNotFoundException) { return(NotFound()); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } var result = await domain.ExecuteListPosts(context); return(View(result)); }
public virtual async Task <IActionResult> PostDelete() { var context = GetPostDeleteDomainContext(); var domain = DomainProvider.GetService <ForumDomainService>(); try { await domain.ExecuteDeletePost(context); return(Ok()); } catch (DomainServiceException ex) { if (ex.InnerException is KeyNotFoundException) { return(NotFound()); } else if (ex.InnerException is ArgumentException || ex.InnerException is ArgumentNullException || ex.InnerException is ArgumentOutOfRangeException) { return(BadRequest(ex.InnerException.Message)); } else if (ex.InnerException is UnauthorizedAccessException) { return(Unauthorized()); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } }
public async Task <IActionResult> Index() { var context = CreateDomainContext(); context.ValueProvider.SetValue("size", 1000); var domain = DomainProvider.GetService <EntityDomainService <Entity.Forum> >(); var result = await domain.ExecuteAsync <IEntityViewModel <Entity.Forum> >(context, "List"); return(View(result)); }
public virtual async Task <IActionResult> Board() { var context = GetBoardDomainContext(); { var domain = DomainProvider.GetService <ForumDomainService>(); var result = await domain.ExecuteListForums(context); return(View(result)); } }
public async Task <IActionResult> Reply() { var context = CreateDomainContext(); var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >(); IEntityEditModel <Thread> threadResult; try { threadResult = await threadDomain.ExecuteAsync <IEntityEditModel <Thread> >(context, "Detail"); return(View(threadResult.Item)); } catch (EntityNotFoundException ex) { return(NotFound()); } }
public async Task <IActionResult> SignOut() { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Home")); } var memberDomain = DomainProvider.GetService <MemberDomainService>(); var context = CreateDomainContext(); await memberDomain.ExecuteAsync(context, "SignOut"); if (Request.Query["returnUrl"].Count > 0) { return(Redirect(Request.Query["returnUrl"][0])); } else { return(RedirectToAction("Index", "Home")); } }
public async Task <IActionResult> SignIn(string username) { if (User.Identity.IsAuthenticated) { return(StatusCode(200)); } var memberDomain = DomainProvider.GetService <MemberDomainService>(); var context = CreateDomainContext(); try { await memberDomain.ExecuteAsync(context, "SignIn"); } catch (UnauthorizedAccessException ex) { return(StatusCode(401, ex.Message)); } return(StatusCode(200)); }
public async Task <IActionResult> Create() { var context = CreateDomainContext(); var domain = DomainProvider.GetService <EntityDomainService <Post> >(); try { var model = await domain.ExecuteAsync <IEntityUpdateModel <Post> >(context, "Update"); return(RedirectToAction("Index", "Thread", new { id = model.Result.Thread.Index })); } catch (ArgumentNullException ex) { return(StatusCode(400, ex.Message)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Create() { var context = CreateDomainContext(); var domain = DomainProvider.GetService <EntityDomainService <Post> >(); try { var model = await domain.ExecuteAsync <IEntityUpdateModel <Post> >(context, "Update"); return(RedirectToAction("Index", "Thread", new { id = model.Result.Thread.Index })); } catch (DomainServiceException ex) { if (ex.InnerException is ArgumentNullException) { return(StatusCode(404, ex.InnerException.Message)); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } }
public async Task <IActionResult> Create() { var context = CreateDomainContext(); var threadDomain = DomainProvider.GetService <EntityDomainService <Thread> >(); var postDomain = DomainProvider.GetService <EntityDomainService <Post> >(); try { var threadUpdateModel = await threadDomain.ExecuteAsync <IEntityUpdateModel <Thread> >(context, "Update"); context.ValueProvider.SetValue("Thread", threadUpdateModel.Result); var postUpdateModel = await postDomain.ExecuteAsync <IEntityUpdateModel <Post> >(context, "Update"); return(RedirectToAction("Index", new { id = threadUpdateModel.Result.Index })); } catch (DomainServiceException ex) { if (ex.InnerException is ArgumentException) { return(StatusCode(400, ex.InnerException.Message)); } else if (ex.InnerException is ArgumentNullException) { return(NotFound()); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } catch (Exception ex) { throw ex; } }
public virtual async Task <IActionResult> PostEdit() { var context = GetPostEditDomainContext(); var domain = DomainProvider.GetService <ForumDomainService>(); try { var post = await domain.ExecuteEditPost(context); return(View(post)); } catch (DomainServiceException ex) { if (ex.InnerException is KeyNotFoundException) { return(NotFound(ex.InnerException.Message)); } else { ExceptionDispatchInfo.Capture(ex).Throw(); throw; } } }
protected virtual EntityDomainService <T> GetEntityDomainService() { return(DomainProvider.GetService <EntityDomainService <T> >()); }
public override void OnActionExecuting(ActionExecutingContext context) { base.OnActionExecuting(context); EntityService = DomainProvider.GetService <EntityDomainService <T> >(); Metadata = EntityDescriptor.GetMetadata <T>(); }