Пример #1
0
        public async Task <IActionResult> Edit(int id, TypeNotable typeNotable)
        {
            if (id != typeNotable.Id)
            {
                ViewBag.ErrorMessage = "لايوجد   بيانات";
                return(View("NotFound"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _repository.Update <TypeNotable>(typeNotable);
                    await _repository.SavaAll();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (_repository.GetTypeNotable(typeNotable.Id) == null)
                    {
                        ViewBag.ErrorMessage = "لايوجد   بيانات";
                        return(View("NotFound"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeNotable));
        }
Пример #2
0
        public async Task <IActionResult> Create(TypeNotable typeNotable)
        {
            if (ModelState.IsValid)
            {
                _repository.Add <TypeNotable>(typeNotable);
                await _repository.SavaAll();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeNotable));
        }