Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("UchPosobieEduFormId,EduFormId,UchPosobieId")] UchPosobieEduForm uchPosobieEduForm)
        {
            if (id != uchPosobieEduForm.UchPosobieEduFormId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(uchPosobieEduForm);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UchPosobieEduFormExists(uchPosobieEduForm.UchPosobieEduFormId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EduFormId"]    = new SelectList(_context.EduForms, "EduFormId", "EduFormName", uchPosobieEduForm.EduFormId);
            ViewData["UchPosobieId"] = new SelectList(_context.UchPosobie, "UchPosobieId", "UchPosobieName", uchPosobieEduForm.UchPosobieId);
            return(View(uchPosobieEduForm));
        }
        /// <summary>
        /// Редактирование привязки
        /// "Учебное пособие - Форма обучения"
        /// </summary>
        /// <param name="UchPosobieId"></param>
        /// <returns></returns>
        public async Task <IActionResult> UchPosobieEduFormCreateOrEdit(int UchPosobieId,
                                                                        int UchPosobieEduFormId)
        {
            // Находим учебное пособие по УИД
            var uchPosobie = await _uchPosobiyaRepository.GetUchPosobieByIdAsync(UchPosobieId);

            if (uchPosobie == null || uchPosobie.UchPosobieId == 0)
            {
                return(NotFound());
            }

            var uchPosobieEduForm = new UchPosobieEduForm();

            uchPosobieEduForm.UchPosobie = uchPosobie;

            // Если UchPosobieEduFormId=0 - новая запись
            // иначе - редактирование
            if (UchPosobieEduFormId != 0)
            {
                uchPosobieEduForm = uchPosobie.EduForms
                                    .SingleOrDefault(uf => uf.UchPosobieEduFormId == UchPosobieEduFormId);
                if (uchPosobieEduForm == null)
                {
                    return(NotFound());
                }
            }

            ViewBag.EduForms = _selectListRepository.GetSelectListEduForms(uchPosobieEduForm.EduFormId);

            return(View(uchPosobieEduForm));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("UchPosobieEduFormId,EduFormId,UchPosobieId")] UchPosobieEduForm uchPosobieEduForm)
        {
            if (ModelState.IsValid)
            {
                _context.Add(uchPosobieEduForm);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EduFormId"]    = new SelectList(_context.EduForms, "EduFormId", "EduFormName", uchPosobieEduForm.EduFormId);
            ViewData["UchPosobieId"] = new SelectList(_context.UchPosobie, "UchPosobieId", "UchPosobieName", uchPosobieEduForm.UchPosobieId);
            return(View(uchPosobieEduForm));
        }
        public async Task <IActionResult> UchPosobieEduFormCreateOrEdit(UchPosobieEduForm uchPosobieEduForm)
        {
            await _uchPosobiyaRepository.UpdateUchPosobieEduFormAsync(uchPosobieEduForm);

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