public IHttpActionResult NewCycle(SwitchCycleClientData data) { UserContext.Constants.NewCycle(); UserContext.Payments.SwitchCycle(); UserContext.Insurances.SwitchCycle(data); return(Ok()); }
public void SwitchCycle(SwitchCycleClientData data) { _rightsManager.CheckRole(AccountRole.Admin); using (var dbTransact = UserContext.Data.Database.BeginTransaction()) { UserContext.Data.BeginFastSave(); ResetIndexValues(data); PayInsuranceMoney(); RemoveStolenInsurances(); ProlongInsurance(); UserContext.Data.SaveChanges(); dbTransact.Commit(); } }
private void ResetIndexValues(SwitchCycleClientData data) { foreach (var pair in _associations) { var corp = UserContext.Accounts.Get(pair.Key); if (corp == null) { continue; //Not found in DB } var cIndex = data.Indexes.ToList().FindIndex(x => x.Key == pair.Key); if (cIndex >= 0) { corp.Index = data.Indexes[cIndex].Value; } corp.InsurancePoints = corp.Index; UserContext.Accounts.Update(corp); UserContext.AddGameEvent(corp.Login, GameEventType.Index, $"Выставлен индекс {corp.Index} и очки страховки {corp.InsurancePoints}"); } }