private ActionResult Details(string key) { ResultDTO <PostInfo> rs = null; Task t1 = Task.Run(() => { PostService service = new PostService(); rs = service.Get(key); }); Task t2 = Task.Run(() => { TownService tService = new TownService(); ViewData["TownItems"] = tService.Get(this.HttpContext); }); Task.WaitAll(new Task[] { t1, t2 }); if (rs.Code < 0) { _log.Error(rs.Message); return(View("Index")); } if (rs.Data == null) { rs.Data = new PostInfo(); } return(View("Details", rs.Data)); }
// GET: Recruitment public ActionResult Index(string key) { if (!string.IsNullOrEmpty(key)) { return(this.Details(key)); } ResultDTO <List <PostInfo> > rs = null; Task t1 = Task.Run(() => { PostService service = new PostService(); rs = service.Get((long)0, 0, "Type='tuyen-dung'", "", ""); }); Task t2 = Task.Run(() => { TownService tService = new TownService(); ViewData["TownItems"] = tService.Get(this.HttpContext); }); Task.WaitAll(new Task[] { t1, t2 }); if (rs.Code < 0) { _log.Error(rs.Message); } if (rs.Data == null) { rs.Data = new List <PostInfo>(); } return(View(rs.Data)); }
private ActionResult PostsForTown(string key) { ResultDTO <List <PostInfo> > rs = null; Task t1 = Task.Run(() => { TownService service = new TownService(); rs = service.GetPosts(key); }); Task t2 = Task.Run(() => { TownService tService = new TownService(); ViewData["TownItems"] = tService.Get(this.HttpContext); }); Task.WaitAll(new Task[] { t1, t2 }); if (rs.Code < 0) { _log.Error(rs.Message); } if (rs.Data == null) { rs.Data = new List <PostInfo>(); } return(View("~/Views/Recruitment/Index.cshtml", rs.Data)); }
public ActionResult Add() { Task t1 = Task.Run(() => { MenuService mService = new MenuService(); ViewData["Menu"] = mService.GetMenuFromXML(this.HttpContext);; }); Task t2 = Task.Run(() => { TownService tService = new TownService(); ViewData["TownItems"] = tService.Get(this.HttpContext); }); Task[] tasks = new Task[] { t1, t2 }; Task.WaitAll(tasks); return(View("Details", new PostInfo())); }
public ActionResult Index(PostInfo obj) { if (obj == null) { return(View("Details", new PostInfo())); } FileService fService = new FileService(); fService.CheckAndSaveImage(obj, Request.Files); PostService service = new PostService(); ResultDTO <PostInfo> rs = null; Task t1 = Task.Run(() => { rs = service.InserOrUpdate(obj); }); Task t2 = Task.Run(() => { MenuService mService = new MenuService(); ViewData["Menu"] = mService.GetMenuFromXML(this.HttpContext);; }); Task t3 = Task.Run(() => { TownService tService = new TownService(); ViewData["TownItems"] = tService.Get(this.HttpContext); }); Task[] tasks = new Task[] { t1, t2, t3 }; Task.WaitAll(tasks); if (rs.Code < 0) { _log.Error(rs.Message); ModelState.AddModelError("Error", rs.Message); return(View("Details", obj)); } return(RedirectToAction("Index", "Posts", new { key = "" })); }
// GET: Posts public ActionResult Index(string key) { PostService service = new PostService(); if (string.IsNullOrEmpty(key)) { ResultDTO <List <PostInfo> > rs = null; Task t1 = Task.Run(() => { rs = service.Get((long)0, 0, "", "", ""); }); Task t2 = Task.Run(() => { MenuService mService = new MenuService(); ViewData["Menu"] = mService.GetMenuFromXML(this.HttpContext); }); Task.WaitAll(new Task[] { t1, t2 }); if (rs.Code < 0) { _log.Error(rs.Message); ModelState.AddModelError("Error", rs.Message); return(View("Index", new List <PostInfo>())); } return(View("Index", rs.Data)); } else { ResultDTO <PostInfo> rs = null; Task t1 = Task.Run(() => { rs = service.Get(key); }); Task t2 = Task.Run(() => { MenuService mService = new MenuService(); ViewData["Menu"] = mService.GetMenuFromXML(this.HttpContext); }); Task t3 = Task.Run(() => { TownService tService = new TownService(); ViewData["TownItems"] = tService.Get(this.HttpContext); }); Task[] tasks = new Task[] { t1, t2, t3 }; Task.WaitAll(tasks); if (rs.Code < 0) { _log.Error(rs.Message); ModelState.AddModelError("Error", rs.Message); return(View("Index", new List <PostInfo>())); } if (rs.Data == null) { return(RedirectToAction("Index", "Posts", new { key = "" })); } return(View("Details", rs.Data)); } }