예제 #1
0
파일: Program.cs 프로젝트: BRozas/immobilis
        static void Main(string[] args)
        {
            using (FluentModel dbContext = new FluentModel())
            {
                // The method, which creates the database on the server.
                UpdateDatabase();

                // Add a new customer.
                //Asegurado newCustomer = new Asegurado
                //{
                //    Nombre = "John Smith",
                //    Apellidos = "*****@*****.**"
                //};
                //dbContext.Add(newCustomer);

                // Commit changes to the database.
                dbContext.SaveChanges();

                // Get the first customer using LINQ and modify it.
                //var customer = dbContext.Customers.FirstOrDefault();

                // Commit changes to the database.
                //dbContext.SaveChanges();

                // Use LINQ to retrieve a customer named John.

                // Delete the customer from the database.

                //// Commit changes to the database.
                //dbContext.SaveChanges();
            }
        }
예제 #2
0
    // The id parameter name should match the DataKeyNames value set on the control
    public void fwNuevaPersona_UpdateItem(int PersonaId)
    {
        try
        {
            using (FluentModel db = new FluentModel())
            {
                Inmobiliaria.Dto.Persona usuario = db.Personas.Single(persona => persona.PersonaId == PersonaId);
                // Load the item here, e.g. item = MyDataLayer.Find(id);
                if (usuario == null)
                {
                    // The item wasn't found
                    ModelState.AddModelError("", String.Format("Item with id {0} was not found", PersonaId));
                    return;
                }
                TryUpdateModel(usuario);
                if (ModelState.IsValid)
                {
                    db.SaveChanges();
                }
                else
                {
                    var errors = ModelState.Values.SelectMany(v => v.Errors);
                }
            }
        }
        catch (Exception ex)
        {

            throw;
        }
    }
예제 #3
0
파일: Program.cs 프로젝트: BRozas/immobilis
 private static void UpdateDatabase()
 {
     using (var context = new FluentModel())
     {
         var schemaHandler = context.GetSchemaHandler();
         EnsureDB(schemaHandler);
     }
 }
예제 #4
0
 public void TestMethod2()
 {
     using (FluentModel db = new FluentModel())
     {
         IList<Persona> personas = db.Personas.ToList();
         db.SaveChanges();
         Assert.IsNotNull(personas);
     }
 }
예제 #5
0
 // The id parameter should match the DataKeyNames value set on the control
 // or be decorated with a value provider attribute, e.g. [QueryString]int id
 public Inmobiliaria.Dto.Persona fwNuevaPersona_GetItem()
 {
     try
     {
         using (FluentModel db = new FluentModel())
         {
             return db.Personas.Single(t => t.PersonaId == Convert.ToInt32(Session["PersonaId"].ToString()));
         }
     }
     catch (Exception)
     {
         //ModalStandart
         throw;
     }
 }
예제 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack) return;
     try
     {
         using (FluentModel db = new FluentModel())
         {
             Persona usuario = db.Personas.Single(t => t.PersonaId == Convert.ToInt32(Session["PersonaId"].ToString()));
             NombreUsuarioSidebar.Text = usuario.Nombre + " " + usuario.Apellido;
             EmailDropMenu.Text = usuario.Email;
             //if(usuario.Perfil. == )
             //this.menuAdministrador.Visible = true;
         }
     }
     catch (Exception)
     {
         Response.Redirect("SessionCerrada.aspx");
     }
 }
예제 #7
0
    public void fwNuevaPersona_InsertItem()
    {
        try
        {
            Persona nuevoUsuario = new Persona();
            TryUpdateModel(nuevoUsuario);
            if (ModelState.IsValid)
            {
                using (FluentModel db = new FluentModel())
                {
                    db.Add(nuevoUsuario);
                    db.SaveChanges();
                }
            }
        }
        catch (Exception ex)
        {

            throw;
        }
    }
예제 #8
0
 protected void btnLoginHome_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(this.txtContrasena.Text.Trim()) || String.IsNullOrEmpty(this.txtEmail.Text.Trim()))
         return;
     using (FluentModel db = new FluentModel())
     {
         if (db.Personas.Any(t => t.Contrasena == this.txtContrasena.Text.Trim() && t.Email == this.txtEmail.Text.Trim()))
         {
             Persona usuario = db.Personas.Single(t => t.Contrasena == this.txtContrasena.Text.Trim() && t.Email == this.txtEmail.Text.Trim());
             Session.Add("PersonaId", usuario.PersonaId);
             Session.Add("Nombre", usuario.Nombre);
             Session.Add("Apellido", usuario.Apellido);
             Session.Add("Rut", usuario.Rut);
             Session.Add("TipoPersona", usuario.TipoPersona);
             Session.Add("NombreUsuario", usuario.NombreUsuario);
             Session.Add("Contrasena", usuario.Contrasena);
             Session.Add("Email", usuario.Email);
             Session.Add("Telefono", usuario.Telefono);
             panelLogInModal.Visible = false;
             panelSession.Visible = true;
         }
         Response.Redirect(RutasFormularios.UsuarioInicio);
     }
 }