public void Update(double value, Goal goal, short day) { _value = value; _goal = goal; _day = day; }
public Standart_Data(int id, double value, Goal goal, short day) { _id = id; _value = value; _goal = goal; _day = day; }
public void Update(User user, Goal goal, DateTime dateStart) { _user = user; _goal = goal; _dateStart = dateStart; }
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(); }
public User_Goal(int id, User user, Goal goal, DateTime dateStart) { if (id == 0) { var res = Model.Instance.client.AddUsers_Goals(user.ID, goal.ID, dateStart); _id = res.Id; } else _id = id; _user = user; _goal = goal; _dateStart = dateStart; }