public int InsertGamerProfile(GamerProfileEN pProfile) { int inserted = default(int); try { connection.Cnn.Open(); inserted = connection.Cnn.Insert(pProfile) ?? default(int); } catch (Exception ex) { inserted = 0; Console.WriteLine(ex.InnerException); EventViewerLoggerDAL.LogError("InsertGamerProfile: " + ex.Message); } finally { connection.Cnn.Close(); } return(inserted); }
public SimpleOperationModel AddPersonNickname(PersonEN pPerson, string pNickname) { SimpleOperationModel result = new SimpleOperationModel(); result.Message = "error"; result.Result = false; try { var profile = personDAL.GetGamerProfileByNickname(pNickname); if (profile == null) { profile = new GamerProfileEN(); profile.Nickname = pNickname; profile.PersonID = pPerson.PersonID; profile.RegDate = DateTime.Now; if (personDAL.InsertGamerProfile(profile) > 0) { result.Result = true; result.Message = "inserted"; } } else { result.Result = false; result.Message = "conflict"; } } catch (Exception ex) { Console.WriteLine(ex.InnerException); EventViewerLoggerBL.LogError("AddPersonNickname: " + ex.Message); } return(result); }
public GamerProfileEN GetGamerProfileByNickname(string pNickname) { GamerProfileEN profile = new GamerProfileEN(); try { connection.Cnn.Open(); profile = connection.Cnn.Query <GamerProfileEN>("SpGamerProfileByNickname", new { nickname = pNickname.Trim() }, commandType: CommandType.StoredProcedure).FirstOrDefault(); } catch (Exception ex) { profile = null; Console.WriteLine(ex.InnerException); EventViewerLoggerDAL.LogError("GetGamerProfileByNickname: " + ex.Message); } finally { connection.Cnn.Close(); } return(profile); }