public SocietateAsigurareExtended(SocietateAsigurare baza) { PropertyInfo[] pis = baza.GetType().GetProperties(); foreach (PropertyInfo pi in pis) { pi.SetValue(this, pi.GetValue(baza)); } }
public JsonResult Edit(SocietateAsigurare societate) { response r = new response(); string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString; int _CURENT_USER_ID = Convert.ToInt32(Session["CURENT_USER_ID"]); SocietatiAsigurareRepository ur = new SocietatiAsigurareRepository(_CURENT_USER_ID, conStr); SocietateAsigurare s = new SocietateAsigurare(_CURENT_USER_ID, conStr); PropertyInfo[] pis = societate.GetType().GetProperties(); foreach (PropertyInfo pi in pis) { pi.SetValue(s, pi.GetValue(societate)); } if (societate.ID == null) // insert { r = s.Insert(); } else // update { r = s.Update(); } return(Json(r, JsonRequestBehavior.AllowGet)); }