Exemplo n.º 1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("PermissionId,OfficerId,MapMenuId,ActiveFlag")] TblMapPermission tblMapPermission)
        {
            if (id != tblMapPermission.PermissionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tblMapPermission);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TblMapPermissionExists(tblMapPermission.PermissionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MapMenuId"] = new SelectList(_context.TblMapMenu, "Id", "Id", tblMapPermission.MapMenuId);
            ViewData["No"]        = new SelectList(_context.TblMapMenu, "Id", "No", tblMapPermission.MapMenu.No);
            ViewData["OfficerId"] = new SelectList(_context.TblOfficer, "OfficerId", "OfficerId", tblMapPermission.OfficerId);
            ViewData["Username"]  = new SelectList(_context.TblOfficer, "OfficerId", "Username", tblMapPermission.Officer.Username);
            return(View(tblMapPermission));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("PermissionId,OfficerId,MapMenuId,ActiveFlag")] TblMapPermission tblMapPermission)
        {
            if (ModelState.IsValid)
            {
                tblMapPermission.PermissionId = Guid.NewGuid();
                _context.Add(tblMapPermission);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MapMenuId"] = new SelectList(_context.TblMapMenu, "Id", "Id", tblMapPermission.MapMenuId);
            ViewData["No"]        = new SelectList(_context.TblMapMenu, "Id", "No", tblMapPermission.MapMenu.No);
            ViewData["OfficerId"] = new SelectList(_context.TblOfficer, "OfficerId", "OfficerId", tblMapPermission.OfficerId);
            ViewData["Username"]  = new SelectList(_context.TblOfficer, "OfficerId", "Username", tblMapPermission.Officer.Username);
            return(View(tblMapPermission));
        }