public void AddArch(int id)
        {
            tFaseArchivo arch = new tFaseArchivo();

            arch.IdFase   = id;
            arch.FechaAdd = DateTime.Now;
            var context   = new PrincipalContext(System.DirectoryServices.AccountManagement.ContextType.Domain);
            var principal = UserPrincipal.FindByIdentity(context, HttpContext.Current.User.Identity.Name);

            arch.UsuarioAdd = String.Concat(principal.GivenName, " ", principal.Surname);

            entity.tFaseArchivos.AddObject(arch);
            entity.SaveChanges();
        }
        public void SaveArch(int id, int ultArchId, HttpPostedFileBase uploadFile, string descrip)
        {
            byte[] tempFile = new byte[uploadFile.ContentLength];
            uploadFile.InputStream.Read(tempFile, 0, uploadFile.ContentLength);

            tFaseArchivo arch = entity.tFaseArchivos.First(m => m.IdFase == id && m.IdArch == ultArchId);

            arch.Nombre = new FileInfo(uploadFile.FileName).Name;
            arch.Tipo   = uploadFile.ContentType;
            decimal len = uploadFile.ContentLength;

            arch.Lenght      = len;
            arch.Contenido   = tempFile;
            arch.Descripcion = descrip;
            entity.tFaseArchivos.ApplyCurrentValues(arch);

            entity.SaveChanges();
        }