public async Task <IActionResult> Create([Bind("Id,OwnerId,RowLabel,ColLabel,ColNumbers,RowNumbers")] Board board) { if (ModelState.IsValid) { _context.Add(board); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["OwnerId"] = new SelectList(_context.Owners, "Id", "Id", board.OwnerId); return(View(board)); }
public async Task <SaveResultModel> SaveAsync() { TrackDataRecords(); try { await dbContext.SaveChangesAsync(); return(new SaveResultModel { IsSuccessful = true, Message = RepoCons.Message.SaveSuccessful }); } catch (DbUpdateConcurrencyException ex) { return(new SaveResultModel { IsSuccessful = false, Message = RepoCons.Message.ConcurrencyOccured }); } catch { return(new SaveResultModel { IsSuccessful = false, Message = RepoCons.Message.Unknown }); } }
// GET: Owners public async Task <IActionResult> Index() { var claimEmail = HttpContext.User.FindFirst("emails").Value; var claimGivenName = HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname").Value; var claimSurName = HttpContext.User.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname").Value; var owner = await _context.Owners.SingleOrDefaultAsync(i => i.EmailAddress == claimEmail); if (owner == null) { owner = new Owner(claimEmail, claimSurName, claimSurName, new List <Board>(), new List <Square>()); await _context.Owners.AddAsync(owner); await _context.SaveChangesAsync(); } else if (owner.SurName != claimSurName || owner.GivenName != claimGivenName) { owner.SurName = claimSurName; owner.GivenName = claimGivenName; await _context.SaveChangesAsync().ConfigureAwait(false); } return(View(owner)); }