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

            if (ModelState.IsValid)
            {
                try
                {
                    _repository.Update <Notable>(notable);
                    await _repository.SavaAll();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (_repository.GetNotable(notable.Id) == null)
                    {
                        ViewBag.ErrorMessage = "لايوجد   بيانات";
                        return(View("NotFound"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(NotablesByReservation),
                                        new { guestReservationId = notable.GuestReservationId }));
            }
            ViewBag.guestReservationId = notable.GuestReservationId;
            ViewData["CountryId"]      = new SelectList(await _repository.GetCountries(), "Id", "Name", notable.CountryId);
            ViewData["JobNotableId"]   = new SelectList(await _repository.GetJobNotables(), "Id", "Name", notable.JobNotableId);
            return(View(notable));
        }
Beispiel #2
0
        public async Task <IActionResult> Create(int guestReservationId, Notable notable)
        {
            if (ModelState.IsValid)
            {
                _repository.Add <Notable>(notable);
                await _repository.SavaAll();

                return(RedirectToAction(nameof(NotablesByReservation),
                                        new { guestReservationId = guestReservationId }));
            }
            ViewBag.guestReservationId = guestReservationId;
            ViewData["CountryId"]      = new SelectList(await _repository.GetCountries(), "Id", "Name", notable.CountryId);
            ViewData["JobNotableId"]   = new SelectList(await _repository.GetJobNotables(), "Id", "Name", notable.JobNotableId);
            return(View(notable));
        }