コード例 #1
0
        // GET: Merge
        public ActionResult Index()
        {
            var list  = new List <MergeViewModel>();
            var prace = db.Prace.Include(p => p.Wydawcy);

            foreach (var p in prace)
            {
                var mod = new MergeViewModel(p.id_pracy);
                mod.jezyk          = p.jezyk;
                mod.rodzaj         = p.rodzaj;
                mod.rok_publikacji = p.rok_publikacji;
                mod.slowa_kluczowe = p.slowa_kluczowe;
                mod.tytul          = p.tytul;
                if (p.Wydawcy != null)
                {
                    mod.wydawca = p.Wydawcy;
                }
                var aut_list = new List <Autorzy>();
                foreach (var a in p.Autorzy)
                {
                    aut_list.Add(a);
                }
                mod.autorzy = aut_list;
                var cat_list = new List <Kategorie>();
                foreach (var c in p.Kategorie)
                {
                    cat_list.Add(c);
                }
                mod.kategorie = cat_list;
                list.Add(mod);
            }
            return(View(list));
        }
コード例 #2
0
        public ActionResult Upload()
        {
            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Content/Files/"), fileName);
                    System.Diagnostics.Debug.WriteLine(path);
                    file.SaveAs(path);
                    TempData["path"] = path;
                    var read   = new WorkPiece();
                    var reader = new iTextSharp.text.pdf.PdfReader(path);
                    read.GetInfoFromPDF(reader, new FileInfo(path));
                    var model = new MergeViewModel(-1);
                    if (read.Author != null)
                    {
                        var auth      = read.Author.Split(',').Select(a => a.Trim());
                        var base_auth = new List <Autorzy>();
                        foreach (var a in auth)
                        {
                            var tmp = new Autorzy();
                            tmp.imie = a;
                            base_auth.Add(tmp);
                        }
                        model.autorzy = base_auth;
                    }
                    if (read.Creator != null)
                    {
                        var wydawca = new Wydawcy();
                        wydawca.nazwa = read.Creator;
                        model.wydawca = wydawca;
                    }
                    if (read.Subject != null)
                    {
                        var cat      = read.Subject.Split(',').Select(a => a.Trim());
                        var base_cat = new List <Kategorie>();
                        foreach (var a in cat)
                        {
                            var tmp = new Kategorie();
                            tmp.nazwa = a;
                            base_cat.Add(tmp);
                        }
                    }
                    model.rodzaj = read.Type;
                    model.jezyk  = read.Language;
                    if (read.CreatedDate != null)
                    {
                        model.rok_publikacji = int.Parse(read.CreatedDate);
                    }
                    model.slowa_kluczowe = read.Keywords;
                    model.tytul          = read.Title;
                    return(View("Edit", model));
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 public ActionResult Edit(int?id)
 {
     try
     {
         if (id != null)
         {
             int Id  = (int)id;
             var p   = db.Prace.Find(id);
             var mod = new MergeViewModel(Id);
             mod.jezyk          = p.jezyk;
             mod.rodzaj         = p.rodzaj;
             mod.rok_publikacji = p.rok_publikacji;
             mod.slowa_kluczowe = p.slowa_kluczowe;
             mod.tytul          = p.tytul;
             if (p.Wydawcy != null)
             {
                 mod.wydawca = p.Wydawcy;
             }
             var aut_list = new List <Autorzy>();
             foreach (var a in p.Autorzy)
             {
                 aut_list.Add(a);
             }
             mod.autorzy = aut_list;
             var cat_list = new List <Kategorie>();
             foreach (var c in p.Kategorie)
             {
                 cat_list.Add(c);
             }
             mod.kategorie = cat_list;
             return(View(mod));
         }
     }
     catch (Exception er) { System.Diagnostics.Debug.WriteLine(er.Message); }
     return(View());
 }