public void Save() { TeamMemo memo = new TeamMemo(); memo.Lv = Lv; memo.Exp = Exp; memo.Power = _power; memo.MemberList = new List <TeamMemberMemo>(); for (int i = 0; i < MemberList.Count; i++) { memo.MemberList.Add(new TeamMemberMemo(MemberList[i])); } Caretaker.Instance.Save <TeamMemo>(memo); }
public void Init() { TeamMemo memo = Caretaker.Instance.Load <TeamMemo>(); if (memo == null) { Lv = 1; Exp = 0; MemberList.Clear(); AddMember(1, true, new Vector2Int(0, 0), 41001, 42001); AddMember(2, true, new Vector2Int(1, 0), 41002, 42001); AddMember(3, true, new Vector2Int(-1, 0), 41002, 42001); //test //AddMember(1, new Vector2Int(0, 0), 41005, 42003); //AddMember(2, new Vector2Int(1, 0), 41006, 42003); //AddMember(3, new Vector2Int(-1, 0), 41006, 42003); //AddMember(4, new Vector2Int(0, 1), 41005, 42003); } else { Lv = memo.Lv; Exp = memo.Exp; _power = memo.Power; TeamMember member; for (int i = 0; i < memo.MemberList.Count; i++) { member = new TeamMember(); member.Init(memo.MemberList[i]); MemberList.Add(member); } } //_power = 50; //SetLv(12, 0); //MemberList[0].IsAttend = true; //MemberList[1].IsAttend = true; //MemberList[2].IsAttend = true; //MemberList[3].IsAttend = true; }
public JsonResult CreateTeamKB(MemoRequest request) { var checkResult = CheckUsername(request.username); if (checkResult != null) { return(checkResult); } if (!CornerCaseCheckHelper.Check(request.teamId, 0, CornerCaseCheckHelper.Id)) { return(JsonReturnHelper.ErrorReturn(301, "Invalid teamId")); } if (!CornerCaseCheckHelper.Check(request.knowledgeName, 50, CornerCaseCheckHelper.Title)) { return(JsonReturnHelper.ErrorReturn(802, "Invalid KnowledgeName.")); } if (!CornerCaseCheckHelper.Check(request.hyperlink, 100, CornerCaseCheckHelper.Description)) { return(JsonReturnHelper.ErrorReturn(803, "Invalid hyperlink.")); } var user = _meshContext.Users.First(u => u.Email == request.username); var team = _meshContext.Teams.FirstOrDefault(t => t.Id == request.teamId); if (team == null) { return(JsonReturnHelper.ErrorReturn(302, "Team does not exist.")); } var memoCollection = _meshContext.TeamMemoCollections.First(p => p.TeamId == team.Id); if (_permissionCheck.CheckTeamPermission(request.username, team) == PermissionCheckHelper.TeamOutsider) { return(JsonReturnHelper.ErrorReturn(801, "Permission denied.")); } var newMemo = new TeamMemo() { Title = request.knowledgeName, CollectionId = memoCollection.Id, Text = request.hyperlink, UserId = user.Id }; try { _meshContext.TeamMemos.Add(newMemo); _meshContext.SaveChanges(); } catch (Exception e) { _logger.LogError(e.ToString()); return(JsonReturnHelper.ErrorReturn(1, "Unexpected error.")); } return(MemoResult(new MemoInfo() { KnowledgeName = request.knowledgeName, HyperLink = request.hyperlink, CreateTime = newMemo.CreatedTime, KnowledgeId = newMemo.Id, UploaderName = request.username })); }