public ResponseModel Guardar()
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new PortafolioContext())
                {
                    if (this.id > 0)
                    {
                        ctx.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        ctx.Entry(this).State = EntityState.Added;
                    }

                    ctx.SaveChanges();
                    rm.SetResponse(true);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(rm);
        }
        public ResponseModel Guardar(HttpPostedFileBase Foto)
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new PortafolioContext())
                {
                    ctx.Configuration.ValidateOnSaveEnabled = false;

                    var eUsuario = ctx.Entry(this);
                    eUsuario.State = EntityState.Modified;

                    // campos que estamos ignorando
                    if (Foto != null)
                    {
                        // Nombre del archivo, es decir, lo reno,renombramos para que no se reptita nunca
                        string archivo = DateTime.Now.ToString("yyyyMMddHHmmss") + Path.GetExtension(Foto.FileName);

                        // la ruta donde lo vamos a guardar
                        Foto.SaveAs(HttpContext.Current.Server.MapPath("~/Uploads/" + archivo));

                        // establecemos en nuectro modelo el nombre de archivo
                        this.Foto = archivo;
                    }
                    else
                    {
                        eUsuario.Property(x => x.Foto).IsModified = false;
                    }

                    if (this.Password == null)
                    {
                        eUsuario.Property(x => x.Password).IsModified = false;
                    }

                    ctx.SaveChanges();
                    rm.SetResponse(true);
                }
            }
            catch (DbEntityValidationException e)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
            return(rm);
        }
        public ResponseModel Eliminar(int id)
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new PortafolioContext())
                {
                    this.id = id;
                    ctx.Entry(this).State = EntityState.Deleted;
                    ctx.SaveChanges();
                    rm.SetResponse(true);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(rm);
        }