Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, WorkSeason workSeason)
        {
            if (id != workSeason.Id)
            {
                ViewBag.ErrorMessage = "لايوجد   بيانات";
                return(View("NotFound"));
            }

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

            ViewData["SeasonId"] = new SelectList(await _repository.GetSeasons(), "Id", "Name", workSeason.SeasonId);
            return(View(workSeason));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(WorkSeason workSeason)
        {
            if (ModelState.IsValid)
            {
                _repository.Add <WorkSeason>(workSeason);
                await _repository.SavaAll();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SeasonId"] = new SelectList(await _repository.GetSeasons(), "Id", "Name");
            return(View(workSeason));
        }