// Update participants in table Contact with IdStatus = 10 public async Task <int> Update_Contact(Model_Contact objContact) { var obj_Contact = new db.Contact(); try { var idcontact = objContact.Idcontact; obj_Contact = await _context.Contact.FirstOrDefaultAsync(x => x.Idcontact == idcontact && x.Idstatut == 10); if (obj_Contact.Idcontact > 0) { obj_Contact.PrenomContact = objContact.PrenomContact; obj_Contact.NomContact = objContact.NomContact; obj_Contact.TelephoneContact = objContact.TelephoneContact; obj_Contact.FonctionContact = objContact.FonctionContact; obj_Contact.EmailContact = objContact.EmailContact; obj_Contact.IdlisteFonction = objContact.IDListeFonction; obj_Contact.PortableContact = objContact.PortableContact; obj_Contact.Idcivilite = Convert.ToByte(objContact.Idcivilite); // update societe await _context.SaveChangesAsync(); return(1); } else { return(0); } } catch (System.Exception) { return(0); } }
// //update Societe public async Task <string> Update_Societe(db.Societe Societe) { var obj_Societe = new db.Societe(); try { var idSociete = Societe.Idsociete; obj_Societe = await _context.Societe.FirstOrDefaultAsync(x => x.Idsociete == idSociete); if (obj_Societe.Idsociete > 0) { obj_Societe.IdlisteFormeJuridique = Societe.IdlisteFormeJuridique; obj_Societe.IdtypeNature = Societe.IdtypeNature; obj_Societe.CodeApe2008 = Societe.CodeApe2008; obj_Societe.Groupe = Societe.Groupe; obj_Societe.Adresse1 = Societe.Adresse1; obj_Societe.Adresse2 = Societe.Adresse2; obj_Societe.CodePostal = Societe.CodePostal; obj_Societe.Ville = Societe.Ville; obj_Societe.TelephoneSociete = Societe.TelephoneSociete; obj_Societe.FaxSociete = Societe.FaxSociete; obj_Societe.EmailSociete = Societe.EmailSociete; obj_Societe.SiteInternet = Societe.SiteInternet; obj_Societe.ActiviteSociete = Societe.ActiviteSociete; obj_Societe.Siret = Societe.Siret; obj_Societe.IdtypeEffectif = Societe.IdtypeEffectif; // obj_Societe.Effectif=Societe.Effectif; obj_Societe.IdtypeCa = Societe.IdtypeCa; // obj_Societe.Ca=Societe.Ca; obj_Societe.IdlistePays = Societe.IdlistePays; // update societe await _context.SaveChangesAsync(); return("update to success"); } else { return("update to error"); } } catch (System.Exception error) { return(error.ToString()); } }
public async Task <db.EnqueteReponse> InsertOrUpdateReponse(int idEnqueteSociete, int idQuestion, int typeStockage, string question) { var reponse = new db.EnqueteReponse(); var res = new db.EnqueteReponse(); var obj = await _context.EnqueteReponse.FirstOrDefaultAsync(x => x.IdenqueteSociete == idEnqueteSociete && x.Idquestion == idQuestion); // if obj ==null ==> Insert 1 item EnqueteReponse if (idEnqueteSociete <= 0 && idQuestion <= 0) { return(res); } if (obj == null) { reponse.IdenqueteSociete = idEnqueteSociete; reponse.Idquestion = idQuestion; // typeStockage== 198 boolen yes/no if (typeStockage == 198) { reponse.ReponseBit = Convert.ToBoolean(question); } // typeStockage== 197 int else if (typeStockage == 197) { reponse.Reponseint = Int32.Parse(question); } // typeStockage== 196 note else if (typeStockage == 196) { reponse.ReponseMemo = question; } // typeStockage== 194 note else if (typeStockage == 194) { reponse.ReponseDate = DateTime.Parse(question); } else { reponse.ReponseTexte = question; } await _context.EnqueteReponse.AddAsync(reponse); await _context.SaveChangesAsync(); res = await _context.EnqueteReponse.FirstOrDefaultAsync(x => x.IdenqueteSociete == idEnqueteSociete && x.Idquestion == idQuestion); } else { // typeStockage== 198 boolen yes/no if (typeStockage == 198) { obj.ReponseBit = Convert.ToBoolean(question); } // typeStockage== 197 int else if (typeStockage == 197) { obj.Reponseint = Int32.Parse(question); } // typeStockage== 196 note else if (typeStockage == 196) { obj.ReponseMemo = question; } // typeStockage== 194 note else if (typeStockage == 194) { obj.ReponseDate = DateTime.Parse(question); } else { obj.ReponseTexte = question; } await _context.SaveChangesAsync(); res = await _context.EnqueteReponse.FirstOrDefaultAsync(x => x.IdenqueteSociete == idEnqueteSociete && x.Idquestion == idQuestion); } return(res); }