コード例 #1
0
        public async Task <ActionResult> CreateAsync(Event evente)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Validation Error");
                }
                Event result = await eventRepo.Add(evente);

                if (result == null)
                {
                    throw new Exception("Invalid Entry");
                }
                return(RedirectToAction(nameof(IndexAsync)));
            }
            catch (Exception exc)
            {
                Debug.WriteLine("Create is unable to save." + exc.Message);
                ModelState.AddModelError("", "Create mislukt. " + exc.Message);
                return(View(evente));
            }
        }