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 = RestaurantViewModel.Parse(getOperation.Result);

            ViewData["Title"] = "Restaurant";

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "New", Controller = "Restaurants", Icon = "fa-search", Text = "Detail"
            });

            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
Пример #2
0
        private async Task <List <RestaurantViewModel> > GetRestaurantViewModels(List <Guid> ids)
        {
            var filterOperation = await _rbo.FilterAsync(x => ids.Contains(x.Id));

            var drList = new List <RestaurantViewModel>();

            foreach (var item in filterOperation.Result)
            {
                drList.Add(RestaurantViewModel.Parse(item));
            }
            return(drList);
        }
Пример #3
0
        public ActionResult <List <RestaurantViewModel> > List()
        {
            var res = _bo.List();

            if (!res.Success)
            {
                return(InternalServerError());
            }
            var list = new List <RestaurantViewModel>();

            foreach (var item in res.Result)
            {
                list.Add(RestaurantViewModel.Parse(item));
            }
            return(list);
        }
        public ActionResult <List <RestaurantViewModel> > List()
        {
            var res = _bo.List();

            if (!res.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            var list = new List <RestaurantViewModel>();

            foreach (var restaurant in res.Result)
            {
                list.Add(RestaurantViewModel.Parse(restaurant));
            }
            return(list);
        }
Пример #5
0
        public ActionResult <RestaurantViewModel> Get(Guid id)
        {
            var res = _bo.Read(id);

            if (res.Success)
            {
                if (res.Result == null)
                {
                    return(NotFound());
                }
                var vm = RestaurantViewModel.Parse(res.Result);
                return(vm);
            }
            else
            {
                return(InternalServerError());
            }
        }
        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 = RestaurantViewModel.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 <RestaurantViewModel>();

            foreach (var item in list)
            {
                var vm = RestaurantViewModel.Parse(item);
                lst.Add(vm);
            }
            return(Ok(lst));
        }
        public ActionResult <RestaurantViewModel> Get(Guid id)
        {
            var res = _bo.Read(id);

            if (res.Success)
            {
                if (res.Result == null)
                {
                    return(NotFound());
                }
                var rvm = RestaurantViewModel.Parse(res.Result);
                return(rvm);
            }
            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 <RestaurantViewModel>();

            foreach (var item in listOperation.Result)
            {
                lst.Add(RestaurantViewModel.Parse(item));
            }

            ViewData["Title"]       = "Restaurants";
            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 <RestaurantViewModel>();

            foreach (var item in listOperation.Result)
            {
                if (!item.IsDeleted)
                {
                    lst.Add(RestaurantViewModel.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 = RestaurantViewModel.Parse(getOperation.Result);

            return(View(vm));
        }
Пример #12
0
        private async Task <RestaurantViewModel> GetRestaurantViewModel(Guid id)
        {
            var getOperation = await _rbo.ReadAsync(id);

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