Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        public void TestCreateAndListCourseAsync()
        {
            RestaurantSeeder.Seed();
            var bo        = new CourseBusinessObject();
            var dr        = new Course("Vegetarian");
            var resCreate = bo.CreateAsync(dr).Result;
            var resGet    = bo.ReadAsync(dr.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Ejemplo n.º 4
0
        public void TestCreateCourseAsync()
        {
            ContextSeeders.Seed();
            var mbo = new CourseBusinessObject();

            var course    = new Course("pizza");
            var resCreate = mbo.CreateAsync(course).Result;
            var resGet    = mbo.ReadAsync(course.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Details(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));
        }
Ejemplo n.º 6
0
        private async Task <CourseViewModel> GetCourseViewModel(Guid id)
        {
            var getOperation = await _cbo.ReadAsync(id);

            return(CourseViewModel.Parse(getOperation.Result));
        }