public ActionResult Create_(Goal goal) { // This method is casting the values from the form and validating the state. // However, since there are some fiels as of now that we are still not adding, // the validate state is failing. We have workarounds to add the missing values // and validate the state. The issue is that we wont know anymore if // there was some legit error coming from the site. var goals = new Goals(SessionProvider.CurrentSession); var anyGoal = goals.GetAll().First(); goal.CreatedOn = DateTime.Now; goal.Venue = anyGoal.Venue; goal.Sport = anyGoal.Sport; goal.UserCreator = anyGoal.UserCreator; ModelState.Where(m => m.Value.Errors != null).ToList().ForEach(e => { var error = e.Value.Errors; error.Clear(); }); UpdateModel(goal); if (ModelState.IsValid) { goals.Add(goal); return RedirectToAction("Details", new { Id = goal.Id }); } GoalViewModel goalViewModel = AutoMapper.Mapper.Map<Goal, GoalViewModel>(goal); return View(goalViewModel); }
// IGoalDb ==================================================================================== public void AddGoal(Goal goal) { Goals.Add(goal); }
public void Append(string goal) { Goals.Add(goal); }
public void SynchEntities() { try { var scales = client.GetAllScales(); foreach (var a in scales) { var scale = Scales.SingleOrDefault(q => q.ID == a.Id); if (scale == null) { Scales.Add(new Scale(a.Id, a.Name)); } else { scale.Update(a.Name); } } var sports = client.GetAllSports(); foreach (var a in sports) { var sport = Sports.SingleOrDefault(q => q.ID == a.Id); if (sport == null) { sport = new Sport(a.Id, a.Name); Sports.Add(sport); } else { sport.Update(a.Name); } var disciplines = client.GetDiscipliniesFromSport(a.Id); foreach (var disc in disciplines) { var discipline = Disciplines.SingleOrDefault(q => q.ID == disc.Id); if (discipline == null) { discipline = new Discipline(disc.Id, disc.Name, sport, Scales.Single(q => q.ID == disc.ScaleId), disc.Description); Disciplines.Add(discipline); } else { discipline.Update(disc.Name, sport, Scales.Single(q => q.ID == disc.ScaleId), disc.Description); } var goals = client.GetGoalsFromDiscipline(disc.Id); foreach (var g in goals) { var goal = Goals.SingleOrDefault(q => q.ID == g.Id); if (goal == null) { goal = new Goal(g.Id, g.Value, discipline, g.PeriodDays, g.Description, Users.SingleOrDefault(q => q.ID == g.OwnerId)); Goals.Add(goal); } else { goal.Update(g.Value, discipline, g.PeriodDays, g.Description, Users.Single(q => q.ID == g.OwnerId)); } var users_goals = client.GetUsers_GoalsFromUser(CurrentUser.ID, goal.ID); foreach (var userg in users_goals) { var user_goal = Users_Goals.SingleOrDefault(q => q.ID == userg.Id); if (user_goal == null) { user_goal = new User_Goal(userg.Id, CurrentUser, goal, userg.DateStart); Users_Goals.Add(user_goal); } else { user_goal.Update(CurrentUser, goal, userg.DateStart); } var stand_datas = client.GetStandart_DataFromGoal(user_goal.Goal.ID); foreach (var s in stand_datas) { var stand = Standarts_Datas.SingleOrDefault(q => q.ID == s.Id); if (stand == null) { stand = new Standart_Data(s.Id, s.Value, user_goal.Goal, s.Day); Standarts_Datas.Add(stand); } else { stand.Update(s.Value, user_goal.Goal, s.Day); } } var users_data = client.GetUsers_DataFromGoal(userg.GoalId); foreach (var us in users_data) { var user_data = Users_Datas.SingleOrDefault(q => q.ID == us.Id); if (user_data == null) { user_data = new User_Data(us.Id, user_goal, us.Value, us.Date); Users_Datas.Add(user_data); } else { user_data.Update(user_goal, us.Value, us.Date); } } } } } } } catch (Exception e) { } SaveBinaryFormat(); }
private void Load(EndianBinaryReader input) { int unk0 = input.ReadInt32(); int unk4 = input.ReadInt32(); int numCollission = input.ReadInt32(); int collisionOffset = input.ReadInt32(); if (input.ReadInt32() != 0xA0) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x10] == 0xA0."); } int unk14 = input.ReadInt32(); int numGoals = input.ReadInt32(); int goalsOffset = input.ReadInt32(); if (input.ReadInt32() != numGoals) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x18] == StageLayout[0x20]."); } if (input.ReadInt32() != 0) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x24] == 0."); } int numBumbers = input.ReadInt32(); int bumpersOffset = input.ReadInt32(); int numJamabars = input.ReadInt32(); int jamabarsOffset = input.ReadInt32(); int numBananas = input.ReadInt32(); int bananasOffset = input.ReadInt32(); int numUnk40 = input.ReadInt32(); int unk40Offset = input.ReadInt32(); int numUnk48 = input.ReadInt32(); int unk48Offset = input.ReadInt32(); int numUnk50 = input.ReadInt32(); int unk50Offset = input.ReadInt32(); int numModelNames = input.ReadInt32(); int modelNamesOffset = input.ReadInt32(); // Looks like a number/offset to some struct of size 0x20, mostly floats int numUnk60 = input.ReadInt32(); int unk60Offset = input.ReadInt32(); int unk68 = input.ReadInt32(); int unk6C = input.ReadInt32(); int numUnk70 = input.ReadInt32(); int unk70Offset = input.ReadInt32(); int unk78 = input.ReadInt32(); int unk7C = input.ReadInt32(); int unk80 = input.ReadInt32(); int unk84 = input.ReadInt32(); int unk88 = input.ReadInt32(); int unk8C = input.ReadInt32(); int unk90 = input.ReadInt32(); if (input.ReadInt32() != 0) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x94] == 0."); } if (input.ReadInt32() != 0) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x98] == 0."); } if (input.ReadInt32() != 0) { throw new InvalidStageLayoutFileException("Expected StageLayout[0x9C] == 0."); } //if (numCollission != 0) Console.WriteLine(numCollission + "/" + collisionOffset); /* * if (unk78 != 0) * { * input.BaseStream.Position = unk7C; * for (int i = 0; i < unk78 + 5; i++) * { * byte[] bytes = input.ReadBytes(0x38); * if (i >= unk78) Console.Write("XXX "); * Console.WriteLine(string.Join(" ", bytes.Select(b => b.ToString("X2")))); * } * * Console.ReadKey(); * } */ input.BaseStream.Position = collisionOffset; for (int i = 0; i < numCollission; i++) { StageLayoutCollision collision = new StageLayoutCollision(); collision.Load(input); Collision.Add(collision); } input.BaseStream.Position = modelNamesOffset; for (int i = 0; i < numModelNames; i++) { StageLayoutModelName modelName = new StageLayoutModelName(); modelName.Load(input); ModelNames.Add(modelName); } input.BaseStream.Position = goalsOffset; for (int i = 0; i < numGoals; i++) { StageLayoutGoal goal = new StageLayoutGoal(); goal.Load(input); Goals.Add(goal); } input.BaseStream.Position = bumpersOffset; for (int i = 0; i < numBumbers; i++) { StageLayoutItem bumper = new StageLayoutItem(); bumper.Load(input); Bumpers.Add(bumper); } input.BaseStream.Position = jamabarsOffset; for (int i = 0; i < numJamabars; i++) { StageLayoutItem jamabar = new StageLayoutItem(); jamabar.Load(input); Jamabars.Add(jamabar); } input.BaseStream.Position = bananasOffset; for (int i = 0; i < numBananas; i++) { StageLayoutBanana banana = new StageLayoutBanana(); banana.Load(input); Bananas.Add(banana); } input.BaseStream.Position = unk40Offset; for (int i = 0; i < numUnk40; i++) { StageLayoutItemExt unk40 = new StageLayoutItemExt(); unk40.Load(input); Unk40.Add(unk40); } input.BaseStream.Position = unk48Offset; for (int i = 0; i < numUnk48; i++) { StageLayoutUnk48 unk48 = new StageLayoutUnk48(); unk48.Load(input); Unk48.Add(unk48); } input.BaseStream.Position = unk50Offset; for (int i = 0; i < numUnk50; i++) { StageLayoutUnk50 unk50 = new StageLayoutUnk50(); unk50.Load(input); Unk50.Add(unk50); } input.BaseStream.Position = unk60Offset; for (int i = 0; i < numUnk60; i++) { StageLayoutUnk60 unk60 = new StageLayoutUnk60(); unk60.Load(input); Unk60.Add(unk60); } input.BaseStream.Position = unk70Offset; for (int i = 0; i < numUnk70; i++) { StageLayoutUnk70 unk70 = new StageLayoutUnk70(); unk70.Load(input); Unk70.Add(unk70); } }
public void AddGoal(Property property) { Goals.Add(new GoalLineVM(property)); UserSettings.Current.AddSelectedProperty(property); }