public ActionResult Create([FromBody] TimeOfDayViewModel todvm)
        {
            var tod = todvm.ToTimeOfDay();
            var res = _bo.Create(tod);

            return(StatusCode(res.Success ? (int)HttpStatusCode.OK : (int)HttpStatusCode.InternalServerError));
        }
Example #2
0
        public async Task <IActionResult> New([Bind("Name")] TimeOfDayViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var tod             = vm.ToTimeOfDay();
                var createOperation = await _bo.CreateAsync(tod);

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