public async Task <IActionResult> Create()
        {
            ViewData["JopId"]      = new SelectList(await _repository.GetJops(), "Id", "Name");
            ViewData["SeasonId"]   = new SelectList(await _repository.GetSeasons(), "Id", "Name");
            ViewData["EmployeeId"] = new SelectList(await _repository.GetEmployees(), "Id", "Name");

            return(View());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(GuideContract guideContract)
        {
            if (ModelState.IsValid)
            {
                var status = await _repository.IsGuideHasContractActive(guideContract.GuideId);

                if (status == true && guideContract.Status == true)
                {
                    ViewData["JopId"]    = new SelectList(await _repository.GetJops(), "Id", "Name");
                    ViewData["SeasonId"] = new SelectList(await _repository.GetSeasons(), "Id", "Name");
                    ViewData["GuideId"]  = new SelectList(await _repository.GetGuides(), "Id", "Name");
                    return(View(guideContract).WithDanger("danger", "لايمكن اضافة العقد . يوجد عقد سابق  "));
                }

                _repository.Add <GuideContract>(guideContract);
                await _repository.SavaAll();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["JopId"]      = new SelectList(await _repository.GetJops(), "Id", "Name");
            ViewData["SeasonId"]   = new SelectList(await _repository.GetSeasons(), "Id", "Name");
            ViewData["EmployeeId"] = new SelectList(await _repository.GetEmployees(), "Id", "Name");
            return(View(guideContract));
        }
Exemplo n.º 3
0
 public async Task <IActionResult> Index()
 {
     return(View(await _repository.GetEmployees()));
 }