public GlobalAttribute GetCaptchaStatus(int IdApplication) { TCRepositoryDataContext context = DataBaseUtils.GetContext(); GlobalAttribute gAtt = new GlobalAttribute(); switch(IdApplication) { case 1: { } break; case 3: { tbl_GlobalAttributesSCM dbAtt = context.tbl_GlobalAttributesSCM.Where(g => g.Name == "Captcha").FirstOrDefault(); gAtt = new GlobalAttribute() { IdGlobalAttribute = dbAtt.IdAttribute, Description = dbAtt.Description, Name = dbAtt.Name }; } break; } if(gAtt ==null) gAtt = new GlobalAttribute(); return gAtt; }
protected void btnSave_Click(object sender, EventArgs e) { CoreLibrary.Configuration.Controller controller = new CoreLibrary.Configuration.Controller(); List<GlobalAttribute> listEntAttributes = new List<GlobalAttribute>(); foreach (var item in lvGlobalAttributes.Items) { GlobalAttribute entAttribute = new GlobalAttribute(); entAttribute.IdGlobalAttribute = Convert.ToInt32(((Label)(item.FindControl("lblIdGlobalAttribute"))).Text); entAttribute.Name = ((Label)(item.FindControl("lblName"))).Text; entAttribute.Value = ((TextBox)(item.FindControl("tbxValue"))).Text; entAttribute.Description = ((Label)(item.FindControl("lblDescription"))).Text; listEntAttributes.Add(entAttribute); } User entCurrenUser = (User)Session["currentUser"]; if (controller.Save(listEntAttributes, entCurrenUser.IdApplication)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "GlobalAttributes", " alert('La información se guardo correctamente');", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "GlobalAttributes", " alert('Error al guardar la información.');", true); } }
public bool Save(GlobalAttribute entGlobalAtt, int IdApplication) { TCRepositoryDataContext context = DataBaseUtils.GetContext(); //List<tbl_GlobalAttributes> listConfiguration = context.tbl_GlobalAttributes.ToList(); try { switch (IdApplication) { case 1: { tbl_GlobalAttributes dbGlobalAttribute = context.tbl_GlobalAttributes.Where(ga => ga.IdAttribute == entGlobalAtt.IdGlobalAttribute).FirstOrDefault(); //GlobalAttribute entConfig = entListConfig.Where(c => c.IdGlobalAttribute == item.IdAttribute).FirstOrDefault(); if (dbGlobalAttribute != null) { dbGlobalAttribute.Value = entGlobalAtt.Value; context.SubmitChanges(); } } break; case 3: tbl_GlobalAttributesSCM dbGlobalSCMAttribute = context.tbl_GlobalAttributesSCM.Where(ga => ga.IdAttribute == entGlobalAtt.IdGlobalAttribute).FirstOrDefault(); //GlobalAttribute entConfig = entListConfig.Where(c => c.IdGlobalAttribute == item.IdAttribute).FirstOrDefault(); if (dbGlobalSCMAttribute != null) { dbGlobalSCMAttribute.Value = entGlobalAtt.Value; context.SubmitChanges(); } break; } return true; } catch { } return false; }