public CreateModel(Socona.ImVehicle.Core.Data.VehicleDbContext context, IAuthorizationService authorizationService, ITownService townService, UserManager <VehicleUser> userManager, IGroupService groupService) { _context = context; _authorizationService = authorizationService; _townService = townService; _userManager = userManager; _groupService = groupService; SecurityPerson = new SecurityPerson(); }
public async Task <IActionResult> OnGetAsync(long?id) { if (id == null) { return(NotFound()); } SecurityPerson = await _context.SecurityPersons .Include(s => s.Group) .Include(s => s.Town).SingleOrDefaultAsync(m => m.Id == id); if (SecurityPerson == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(long?id) { if (id == null) { return(NotFound()); } SecurityPerson = await _context.SecurityPersons.FindAsync(id); if (SecurityPerson != null) { _context.SecurityPersons.Remove(SecurityPerson); await _context.SaveChangesAsync(); } return(Redirect(Url.GetLocalUrl(ReturnUrl))); }
public async Task <IActionResult> OnGetAsync(long?id) { if (id == null) { return(NotFound()); } SecurityPerson = await _context.SecurityPersons .Include(s => s.Group) .Include(s => s.Town).SingleOrDefaultAsync(m => m.Id == id); if (SecurityPerson == null) { return(NotFound()); } ViewData["GroupId"] = new SelectList(_context.Groups, "Id", "Id"); ViewData["TownId"] = new SelectList(_context.Towns, "Id", "Id"); return(Page()); }
private void CreateThreeObjects() { using (DbContextSecurityObject dbContextConnectionClass = new DbContextSecurityObject()) { dbContextConnectionClass.ResetDatabase(); SecurityCompany company = new SecurityCompany(); company.Name = "1"; company.Description = "1"; dbContextConnectionClass.Add(company); for (int i = 1; i < 4; i++) { string indexString = i.ToString(); SecurityPerson person = new SecurityPerson(); person.Name = indexString; person.Description = indexString; person.SecurityCompany = company; dbContextConnectionClass.Add(person); } dbContextConnectionClass.SaveChanges(); } }