public async Task <IActionResult> Details(Guid?id) { if (id == null) { return(RecordNotFound()); } var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var vm = CourseViewModel.Parse(getOperation.Result); ViewData["Title"] = "Course"; var crumbs = GetCrumbs(); crumbs.Add(new BreadCrumb() { Action = "New", Controller = "Courses", Icon = "fa-search", Text = "Detail" }); ViewData["BreadCrumbs"] = crumbs; return(View(vm)); }
private async Task <List <CourseViewModel> > GetCourseViewModels(List <Guid> ids) { var filterOperation = await _cbo.FilterAsync(x => ids.Contains(x.Id)); var drList = new List <CourseViewModel>(); foreach (var item in filterOperation.Result) { drList.Add(CourseViewModel.Parse(item)); } return(drList); }
public ActionResult <List <CourseViewModel> > List() { var res = _bo.List(); if (!res.Success) { return(InternalServerError()); } var list = new List <CourseViewModel>(); foreach (var item in res.Result) { list.Add(CourseViewModel.Parse(item)); } return(list); }
public async Task <IActionResult> GetAsync(Guid id) { var getResult = await _bo.ReadAsync(id); if (!getResult.Success) { return(InternalServerError(getResult.Exception)); } var item = getResult.Result; if (item == null) { return(NotFound()); } var vm = CourseViewModel.Parse(item); return(Ok(vm)); }
public async Task <IActionResult> ListAsync() { var listResult = await _bo.ListNonDeletedAsync(); if (!listResult.Success) { return(InternalServerError(listResult.Exception)); } var list = listResult.Result; var lst = new List <CourseViewModel>(); foreach (var item in list) { var vm = CourseViewModel.Parse(item); lst.Add(vm); } return(Ok(lst)); }
public ActionResult <CourseViewModel> Get(Guid id) { var res = _bo.Read(id); if (res.Success) { if (res.Result == null) { return(NotFound()); } var vm = CourseViewModel.Parse(res.Result); return(vm); } else { return(InternalServerError()); } }
public ActionResult <CourseViewModel> Get(Guid id) { var res = _bo.Read(id); if (res.Success) { if (res.Result == null) { return(NotFound()); } var cvm = CourseViewModel.Parse(res.Result); return(cvm); } else { return(new ObjectResult(HttpStatusCode.InternalServerError)); } }
public async Task <IActionResult> Index() { var listOperation = await _bo.ListNonDeletedAsync(); if (!listOperation.Success) { return(OperationErrorBackToIndex(listOperation.Exception)); } var lst = new List <CourseViewModel>(); foreach (var item in listOperation.Result) { lst.Add(CourseViewModel.Parse(item)); } ViewData["Title"] = "Courses"; ViewData["BreadCrumbs"] = GetCrumbs(); ViewData["DeleteHref"] = GetDeleteRef(); return(View(lst)); }
public async Task <IActionResult> Index() { var listOperation = await _bo.ListAsync(); if (!listOperation.Success) { return(View("Error", new ErrorViewModel() { RequestId = listOperation.Exception.Message })); } var lst = new List <CourseViewModel>(); foreach (var item in listOperation.Result) { if (!item.IsDeleted) { lst.Add(CourseViewModel.Parse(item)); } } return(View(lst)); }
public async Task <IActionResult> Edit(Guid?id) { if (id == null) { return(NotFound()); } var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(View("Error", new ErrorViewModel() { RequestId = getOperation.Exception.Message })); } if (getOperation.Result == null) { return(NotFound()); } var vm = CourseViewModel.Parse(getOperation.Result); return(View(vm)); }
private async Task <CourseViewModel> GetCourseViewModel(Guid id) { var getOperation = await _cbo.ReadAsync(id); return(CourseViewModel.Parse(getOperation.Result)); }