コード例 #1
0
        public string ModifyData(string prefix, string serial, string wholeSerial, string nameCn, string nameEn, string nameJp,
                                 string tag, string magnetLink, string torrentLink, string pictureLink, string companyName, string IsStored)
        {
            var db      = new CoreDriverContext();
            var newData = new CoreVideo();

            newData.Prefix      = prefix;
            newData.Serial      = serial;
            newData.WholeSerial = wholeSerial;
            newData.Tags        = tag;
            newData.MagnetLink  = magnetLink;
            newData.TorrentLink = torrentLink;
            newData.PictureLink = pictureLink;
            newData.CompanyName = companyName;
            newData.IsStored    = IsStored;
            try
            {
                db.CoreVideo.Update(newData);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return("501");
            }
            finally
            {
                db.Dispose();
            }

            return("200");
        }
コード例 #2
0
        public string AddNewData(CoreVideo newData)
        {
            var db   = new CoreDriverContext();
            var data = db.CoreVideo.Where(v => v.WholeSerial == newData.WholeSerial);

            if (data.Any())
            {
                return("502");
            }


            try
            {
                db.CoreVideo.Add(newData);

                //Add new actress
                var actress = db.CoreActress.Where(v => v.NameCn == newData.ActressName);
                if (!actress.Any())
                {
                    var newActress = new CoreActress()
                    {
                        NameCn = newData.ActressName,
                    };
                    db.CoreActress.Add(newActress);
                }

                db.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return("501");
                //throw;
            }
            finally
            {
                db.Dispose();
            }

            return("200");
        }
コード例 #3
0
        public string AddNewData(string prefix, string serial, string wholeSerial, string nameCn, string nameEn, string nameJp,
                                 string tag, string magnetLink, string torrentLink, string pictureLink, string companyName, string IsStored)
        {
            if (string.IsNullOrEmpty(wholeSerial))
            {
                wholeSerial = prefix + "-" + serial;
            }
            else
            {
                if (wholeSerial.Contains("-"))
                {
                    var ws = wholeSerial.Split('-');
                    if (ws.Length == 2)
                    {
                        prefix = ws[0];
                        serial = ws[1];
                    }
                }
            }

            var db   = new CoreDriverContext();
            var data = db.CoreVideo.Where(v => v.WholeSerial == wholeSerial);

            if (data.Any())
            {
                return("502");
            }

            var newData = new CoreVideo()
            {
                Prefix      = prefix,
                Serial      = serial,
                WholeSerial = wholeSerial,
                Tags        = tag,
                MagnetLink  = magnetLink,
                TorrentLink = torrentLink,
                PictureLink = pictureLink,
                CompanyName = companyName,
                ActressName = nameCn
            };

            try
            {
                db.CoreVideo.Add(newData);

                //Add new actress
                var actress = db.CoreActress.Where(v => v.NameCn == nameCn);
                if (!actress.Any())
                {
                    var newActress = new CoreActress()
                    {
                        NameCn      = nameCn,
                        NameEn      = nameEn,
                        NameJp      = nameJp,
                        PictureLink = pictureLink
                    };
                    db.CoreActress.Add(newActress);
                }

                db.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return("501");
                //throw;
            }
            finally
            {
                db.Dispose();
            }

            return("200");
        }