/// <summary> /// Deprecated Method for adding a new object to the PARTICIPANTS EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPARTICIPANTS(PARTICIPANT pARTICIPANT) { base.AddObject("PARTICIPANTS", pARTICIPANT); }
/// <summary> /// Create Participant and try to migrate some details from user table. /// </summary> public void createParticipant(int userid,int sessionid) { try { USER userData = (from user in dbpollContext.USERS where user.USER_ID == userid select user).First<USER>(); var participants = from part in dbpollContext.PARTICIPANTS join data in dbpollContext.PARTICIPANT_DATA on part.PARTICIPANT_ID equals data.PARTICIPANT_ID where part.USER_ID == userData.USER_ID select new participantModel { userweight = (int)data.USER_WEIGHT, name = data.NAME, address = data.ADDRESS, city = data.CITY, postcode = data.POSTCODE, state = data.STATE, country = data.COUNTRY, department = data.DEPARTMENT, company = data.COMPANY, email = data.EMAIL, fax = data.FAX, phone = data.PHONE, title = data.TITLE }; PARTICIPANT p = new PARTICIPANT(); PARTICIPANT_DATA partdata = new PARTICIPANT_DATA(); p.PARTICIPANT_ID = getMaxParticipantID() + 1; p.USER_ID = userid; p.SESSION_ID = sessionid; partdata.DATA_ID = getMaxDataID() + 1; partdata.PARTICIPANT_ID = p.PARTICIPANT_ID; partdata.NAME = userData.NAME; // See if we can set data from a previous participant entry if (participants.ToArray().Length > 0) { participantModel participant = participants.First<participantModel>(); partdata.USER_WEIGHT = participant.userweight; partdata.ADDRESS = participant.address; partdata.CITY = participant.city; partdata.POSTCODE = participant.postcode; partdata.STATE = participant.state; partdata.COUNTRY = participant.country; partdata.DEPARTMENT =participant.department; partdata.COMPANY = partdata.COMPANY; partdata.EMAIL = partdata.EMAIL; partdata.FAX = participant.fax; partdata.PHONE= participant.phone; partdata.TITLE= participant.title; } dbpollContext.AddToPARTICIPANTS(p); dbpollContext.AddToPARTICIPANT_DATA(partdata); dbpollContext.SaveChanges(); } catch (Exception e) { throw (e); } }
/// <summary> /// Create a new PARTICIPANT object. /// </summary> /// <param name="pARTICIPANT_ID">Initial value of the PARTICIPANT_ID property.</param> /// <param name="cREATED_AT">Initial value of the CREATED_AT property.</param> /// <param name="uSER_ID">Initial value of the USER_ID property.</param> /// <param name="sESSION_ID">Initial value of the SESSION_ID property.</param> public static PARTICIPANT CreatePARTICIPANT(global::System.Int32 pARTICIPANT_ID, global::System.DateTime cREATED_AT, global::System.Int32 uSER_ID, global::System.Int32 sESSION_ID) { PARTICIPANT pARTICIPANT = new PARTICIPANT(); pARTICIPANT.PARTICIPANT_ID = pARTICIPANT_ID; pARTICIPANT.CREATED_AT = cREATED_AT; pARTICIPANT.USER_ID = uSER_ID; pARTICIPANT.SESSION_ID = sESSION_ID; return pARTICIPANT; }