public void UpdateKillStat(int playerId, int mobId) { List <KillStat> currentEntityList = _context.KillStats .Select(ks => ks) .Where(ks => ks.PlayerId == playerId && ks.MobId == mobId) .ToList(); if (currentEntityList.Count == 0) { var newEntity = new KillStat { PlayerId = playerId, MobId = mobId, Quantity = 1 }; _context.Add(newEntity); } else { var currentEntity = currentEntityList[0]; var newEntity = new KillStat { Id = currentEntity.Id, PlayerId = playerId, MobId = mobId, Quantity = currentEntity.Quantity + 1 }; _context.Entry(currentEntity).CurrentValues.SetValues(newEntity); } }
//[Authorize(Roles = "Admin")] public async Task <IActionResult> Create([Bind("Age,Attrition,BusinessTravel,DailyRate,Department,DistanceFromHome,Education,EducationField,EmployeeCount,EmployeeNumber,EnvironmentSatisfaction,Gender,HourlyRate,JobInvolvement,JobLevel,JobRole,JobSatisfaction,MaritalStatus,MonthlyIncome,MonthlyRate,NumCompaniesWorked,Over18,OverTime,PercentSalaryHike,PerformanceRating,RelationshipSatisfaction,StandardHours,StockOptionLevel,TotalWorkingYears,TrainingTimesLastYear,WorkLifeBalance,YearsAtCompany,YearsInCurrentRole,YearsSinceLastPromotion,YearsWithCurrManager")] Cmpg323Project2Dataset cmpg323Project2Dataset) { if (ModelState.IsValid) { _context.Add(cmpg323Project2Dataset); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cmpg323Project2Dataset)); }