public Cart() { Cart c = this.GetFromSession(); if (c != null) { ctx = c.ctx; WhyNotValid = c.WhyNotValid; } else { ctx = new ASPNETDBEntities(); WhyNotValid = new List <string>(); this.AddToSession(); } }
public static void Importar(XmlDocument oXml) { try { // criacao do modelo (persistencia) ASPNETDBEntities oContext = new ASPNETDBEntities(); // loop nos nós do xml para leitura e posterior gravacao XmlNodeList oNodeRegistros = oXml.SelectNodes("/importacao/tabela/registros/registro"); String sCodigo = String.Empty; String sDescricao = String.Empty; foreach (XmlNode oNodeRegistro in oNodeRegistros) { foreach (XmlNode oNodeCampo in oNodeRegistro.ChildNodes) { if (oNodeCampo.Attributes["nome"].Value == "Codigo") { sCodigo = oNodeCampo.Attributes["valor"].Value; } if (oNodeCampo.Attributes["nome"].Value == "Descricao") { sDescricao = oNodeCampo.Attributes["valor"].Value; } } if (!String.IsNullOrEmpty(sCodigo) && !String.IsNullOrEmpty(sDescricao)) { Produtos oProduto = new Produtos(); oProduto.id_Produto = Convert.ToInt16(sCodigo); oProduto.Descricao = sDescricao; oContext.AddToProdutos(oProduto); } } // persistir dados oContext.SaveChanges(); } catch (Exception ex) { // tratar erro throw ex; } }
protected void UploadButton_Click(object sender, EventArgs e) { if (FileUpload.HasFile) { ASPNETDBEntities upload = new ASPNETDBEntities(); string path = Server.MapPath("~/StudentsOnly/UploadedFiles/"); WebsiteUpload wu = new WebsiteUpload(); wu.Title = TitleTextBox.Text; wu.Description = DescriptionTextBox.Text; wu.File = FileUpload.FileName; upload.WebsiteUploads.AddObject(wu); upload.SaveChanges(); FileUpload.PostedFile.SaveAs(path + FileUpload.FileName); UploadSuccessfulLabel.Text = "Your file has successfully been uploaded!"; } else { UploadSuccessfulLabel.Text = "Please select a file."; } }
public IdentityRepository() { _context = new ASPNETDBEntities(); }
public void Empty() { ctx = new ASPNETDBEntities(); }
public void history(Guid userId) { ASPNETDBEntities db = new ASPNETDBEntities(); var query = db.Bookings.SingleOrDefault(x => x.customer_id == userId); }