示例#1
0
        public async Task <IActionResult> Edit(int id)
        {
            var level = await _repository.GetLevel(id);

            if (level == null)
            {
                ViewBag.ErrorMessage = "لايوجد   بيانات";
                return(View("NotFound"));
            }

            return(View(level));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, TypeOfProduct typeOfProduct)
        {
            if (id != typeOfProduct.Id)
            {
                ViewBag.ErrorMessage = "لايوجد   بيانات";
                return(View("NotFound"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _repository.Update <TypeOfProduct>(typeOfProduct);
                    await _repository.SavaAll();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (_repository.GetLevel(typeOfProduct.Id) == null)
                    {
                        ViewBag.ErrorMessage = "لايوجد   بيانات";
                        return(View("NotFound"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeOfProduct));
        }