public int ApiCalculateXPtoWidth(UserDetail myUserDetail, UserInfo myUserInfo) { int width = 1; try { using (ParmakYarisiDBDataContext DB = new ParmakYarisiDBDataContext()) { var query = from allLevel in DB.Levels where allLevel.LevelID == myUserInfo.UserLevelInfo.LevelID - 1 select allLevel; foreach (Level l in query) { width = 100 * (myUserDetail.UserXP - l.LevelRequiredXP) / (myUserInfo.UserLevelInfo.LevelRequiredXP - l.LevelRequiredXP); int a = 3; break; } } } catch (Exception ex) { CatchExLinqToApiOnDBLayer.myCatchException(ex, "ApiCalculateXPtoWidth"); } return(width); }
public int pyCreateUser(User myNewUser) { try { using (ParmakYarisiDBDataContext DB = new ParmakYarisiDBDataContext()) { DB.Users.InsertOnSubmit(myNewUser); DB.SubmitChanges(); UserDetail myNewUserDetail = new UserDetail(); myNewUserDetail.UserID = myNewUser.UserID; myNewUserDetail.UserXP = 0; myNewUserDetail.UserPoint = 0; myNewUserDetail.UserLevelID = 1; myNewUserDetail.UserCityID = 1; DB.UserDetails.InsertOnSubmit(myNewUserDetail); DB.SubmitChanges(); } } catch (Exception ex) { CatchExLinqToApiOnDBLayer.myCatchException(ex, "pyCreateUser"); return(0); } return(1); }
public String[,] pyGetTopTen() { try { String[,] topTen = new String[10, 2]; int count = 0; using (ParmakYarisiDBDataContext DB = new ParmakYarisiDBDataContext()) { var query = from ud in DB.UserDetails join u in DB.Users on ud.UserID equals u.UserID orderby ud.UserXP descending select new { u.UserNickname, ud.UserXP }; foreach (var u in query) { topTen[count, 0] = u.UserNickname; topTen[count, 1] = u.UserXP.ToString(); count++; } return(topTen); } } catch (Exception ex) { CatchExLinqToApiOnDBLayer.myCatchException(ex, "pyGetTopTen()"); return(null); } }
public User pyLogin(string myEmail, string myPassword) { User existUser = new User(); try { using (ParmakYarisiDBDataContext DB = new ParmakYarisiDBDataContext()) { var query = from selectedUser in DB.Users where selectedUser.UserEmail == myEmail where selectedUser.UserPassword == myPassword select selectedUser; foreach (User u in query) { return(u); } } return(null); } catch (Exception ex) { CatchExLinqToApiOnDBLayer.myCatchException(ex, "pyLogin(string myEmail, string myPassword)"); return(null); } }
public UserDetail ApiFindUserDetail(User myUser) { UserDetail existUserDetail = new UserDetail(); try { using (ParmakYarisiDBDataContext DB = new ParmakYarisiDBDataContext()) { var query = from selectedUserDetail in DB.UserDetails where selectedUserDetail.UserID == myUser.UserID select selectedUserDetail; foreach (UserDetail d in query) { existUserDetail = d; } } } catch (Exception ex) { CatchExLinqToApiOnDBLayer.myCatchException(ex, "ApiFindUserDetail"); return(null); } return(existUserDetail); }
public UserInfo ApiGenerateUserInfo(User myUser) { UserInfo existUserInfo = new UserInfo(); try { using (ParmakYarisiDBDataContext DB = new ParmakYarisiDBDataContext()) { var query = from selectedUserDetail in DB.UserDetails where selectedUserDetail.UserID == myUser.UserID select selectedUserDetail; foreach (UserDetail d in query) { existUserInfo.UserCityInfo = d.City; existUserInfo.UserLevelInfo = d.Level; } } } catch (Exception ex) { CatchExLinqToApiOnDBLayer.myCatchException(ex, "ApiGenerateUserInfo"); return(null); } return(existUserInfo); }
public static UserDetail ApiCalculateXPtoLevel(UserDetail myUserDetail, UserInfo myUserInfo) { UserDetail newMyUserDetail = null; // Kullanicinin son XP'si level atlamak icin yeterliyse burasi calisir. // Aksi halde bir islem yapilmaz. Eski levelName geri doner. try { if (myUserDetail.UserXP > myUserInfo.UserLevelInfo.LevelRequiredXP) { using (ParmakYarisiDBDataContext DB = new ParmakYarisiDBDataContext()) { var query = from allLevel in DB.Levels where allLevel.LevelID == myUserInfo.UserLevelInfo.LevelID + 1 select allLevel; foreach (Level l in query) { UserDetail newUserDetail = (from u in DB.UserDetails where u.UserID == myUserDetail.UserID select u).Single(); newUserDetail.UserLevelID = l.LevelID; DB.SubmitChanges(); newMyUserDetail = newUserDetail; break; } } } else { return(myUserDetail); } } catch (Exception ex) { CatchExLinqToApiOnDBLayer.myCatchException(ex, "ApiCalculateXPtoLevel"); } return(newMyUserDetail); }
public static UserDetail pyUpdateXP(Guid myUserID, int myXP) { UserDetail myNewUserDetail = null; try { using (ParmakYarisiDBDataContext DB = new ParmakYarisiDBDataContext()) { UserDetail myUserDetail = (from u in DB.UserDetails where u.UserID == myUserID select u).Single(); myUserDetail.UserXP += myXP; DB.SubmitChanges(); myNewUserDetail = myUserDetail; } } catch (Exception ex) { CatchExLinqToApiOnDBLayer.myCatchException(ex, "pyUpdateXP"); } return(myNewUserDetail); }