public async Task <ActionResult> AddDoc(IFormCollection formCollection, IFormFile files)
        {
            Correspondencia.DB.DB db     = new Correspondencia.DB.DB();
            AddDocModel           addDoc = new AddDocModel();

            string folio        = formCollection["FOLIO"];
            int    type         = Int32.Parse(formCollection["TYPE"]);
            int    destinatario = Int32.Parse(formCollection["DESTINATARIO"]);
            int    remitente    = Int32.Parse(formCollection["REMITENTE"]);
            string resumen      = formCollection["RESUMEN"];
            int    turnado      = 1;
            int    estado       = 0;
            int    copia        = 1;
            string goodPath     = Path.Combine("/", files.FileName);
            // full path to file in temp location
            string path = Path.Combine("wwwroot/",
                                       files.FileName);

            if (files.Length > 0)
            {
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await files.CopyToAsync(stream);
                }
            }

            addDoc.ID_REM  = remitente;
            addDoc.ID_DIR  = destinatario;
            addDoc.ID_TIP  = type;
            addDoc.FOLIO   = folio;
            addDoc.TURNADO = turnado;
            addDoc.ESTADO  = estado;
            addDoc.RESUMEN = resumen;
            addDoc.PDF     = goodPath;
            addDoc.COPIA   = copia;

            db.insertDocument(addDoc);

            return(RedirectToAction("Home", "Home"));
        }
Esempio n. 2
0
        public void insertDocument(AddDocModel addDoc)
        {
            using (connection)
            {
                connection.Open();

                cmd             = new SqlCommand("sp_InsertDocumento", connection);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ID_REM", addDoc.ID_REM);
                cmd.Parameters.AddWithValue("@ID_DIR", addDoc.ID_DIR);
                cmd.Parameters.AddWithValue("@ID_TIP", addDoc.ID_TIP);
                cmd.Parameters.AddWithValue("@FOLIO", addDoc.FOLIO);
                cmd.Parameters.AddWithValue("@TURNADO", addDoc.TURNADO);
                cmd.Parameters.AddWithValue("@ESTADO", addDoc.ESTADO);
                cmd.Parameters.AddWithValue("@RESUMEN", addDoc.RESUMEN);
                cmd.Parameters.AddWithValue("@PDF", addDoc.PDF);
                cmd.Parameters.AddWithValue("@COPIA", addDoc.COPIA);

                cmd.ExecuteNonQuery();
            }
            connection.Close();
        }