Beispiel #1
0
        public ActionResult Create([FromBody] RestaurantViewModel vm)
        {
            var r   = vm.ToRestaurant();
            var res = _bo.Create(r);

            return(StatusCode(res.Success ? (int)HttpStatusCode.OK : (int)HttpStatusCode.InternalServerError));
        }
Beispiel #2
0
        public ActionResult Create([FromBody] RestaurantViewModel vm)
        {
            var rt  = vm.ToRestaurant();
            var res = _bo.Create(rt);

            return(res.Success ? Ok() : InternalServerError());
        }
        public async Task <IActionResult> Create([Bind("Name", "Address", "OpenningHours", "ClosingHours", "ClosingDays", "TableCount")] RestaurantViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var Restaurant      = vm.ToRestaurant();
                var createOperation = await _bo.CreateAsync(Restaurant);

                if (!createOperation.Success)
                {
                    return(View("Error", new ErrorViewModel()
                    {
                        RequestId = createOperation.Exception.Message
                    }));
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vm));
        }