コード例 #1
0
        public async Task <IActionResult> OnGetAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Staff = await _context.Staff.FirstOrDefaultAsync(m => m.ID == id);

            Rank = await _context.Rank.FirstOrDefaultAsync(m => m.ID == Staff.RankID);

            Position = await _context.Position.FirstOrDefaultAsync(m => m.ID == Staff.PositionID);

            if (Staff == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #2
0
ファイル: Edit.cshtml.cs プロジェクト: ditor4ik/WebBD_GIBDD
        public async Task <IActionResult> OnGetAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            SelPosition = _context.Position.Select(p =>
                                                   new SelectListItem
            {
                Value = p.ID.ToString(),
                Text  = p.NamePosition
            }).ToList();

            SelRank = _context.Rank.Select(r =>
                                           new SelectListItem
            {
                Value = r.ID.ToString(),
                Text  = r.NameRank
            }).ToList();
            SelGender = new List <SelectListItem>
            {
                new SelectListItem {
                    Value = "Мужчина", Text = "Мужчина"
                },
                new SelectListItem {
                    Value = "Женщина", Text = "Женщина"
                }
            };

            Staff = await _context.Staff.FirstOrDefaultAsync(m => m.ID == id);

            Rank = await _context.Rank.FirstOrDefaultAsync(m => m.ID == Staff.RankID);

            Position = await _context.Position.FirstOrDefaultAsync(m => m.ID == Staff.PositionID);

            if (Staff == null)
            {
                return(NotFound());
            }
            return(Page());
        }