public string ModifyData(string prefix, string nameCn, string nameEn, string nameJp, string birth, string chest,
                                 string tags, string pictureLink)
        {
            var db      = new CoreDriverContext();
            var newData = new CoreActress()
            {
                NameCn      = nameCn,
                NameEn      = nameEn,
                NameJp      = nameJp,
                Birth       = birth,
                Chest       = chest,
                Tags        = tags,
                PictureLink = pictureLink
            };

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

            return("200");
        }
Exemple #2
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");
        }
Exemple #3
0
        public string GetAllData()
        {
            var db = new CoreDriverContext();

            var jsonArray = new JArray();

            foreach (var v in db.CoreVideo.ToList())
            {
                var json = JsonConvert.SerializeObject(v);
                jsonArray.Add(json);
            }
            db.Dispose();

            return(jsonArray.ToString());
        }
Exemple #4
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");
        }
        public string GetDataByTags(string tag)
        {
            if (string.IsNullOrEmpty(tag.Trim()))
            {
                return(string.Empty);
            }

            tag = tag.Trim();
            var db = new CoreDriverContext();

            var jsonArray = new JArray();
            var videos    = db.CoreActress.Where(v => v.Tags.Contains(tag));

            foreach (var v in videos)
            {
                var json = JsonConvert.SerializeObject(v);
                jsonArray.Add(json);
            }
            db.Dispose();

            return(jsonArray.ToString());
        }
        public string GetDataByNameJp(string name)
        {
            if (string.IsNullOrEmpty(name.Trim()))
            {
                return(string.Empty);
            }

            name = name.Trim();
            var db = new CoreDriverContext();

            var jsonArray = new JArray();
            var actresses = db.CoreActress.Where(v => v.NameCn == name);

            foreach (var v in actresses)
            {
                var json = JsonConvert.SerializeObject(v);
                jsonArray.Add(json);
            }
            db.Dispose();

            return(jsonArray.ToString());
        }
Exemple #7
0
        public string GetDataByWholeSerial(string wholeSerial)
        {
            if (string.IsNullOrEmpty(wholeSerial.Trim()))
            {
                return(string.Empty);
            }

            wholeSerial = wholeSerial.Trim();
            var db = new CoreDriverContext();

            var jsonArray = new JArray();
            var videos    = db.CoreVideo.Where(v => v.WholeSerial == wholeSerial);

            foreach (var v in videos)
            {
                var json = JsonConvert.SerializeObject(v);
                jsonArray.Add(json);
            }
            db.Dispose();

            return(jsonArray.ToString());
        }
Exemple #8
0
        public string GetDataByPrefix(string prefix)
        {
            if (string.IsNullOrEmpty(prefix.Trim()))
            {
                return(string.Empty);
            }

            prefix = prefix.Trim();
            var db = new CoreDriverContext();

            var jsonArray = new JArray();
            var videos    = db.CoreVideo.Where(v => v.Prefix == prefix);

            foreach (var v in videos)
            {
                var json = JsonConvert.SerializeObject(v);
                jsonArray.Add(json);
            }
            db.Dispose();

            return(jsonArray.ToString());
        }
Exemple #9
0
        public string GetDataByCompany(string companyName)
        {
            if (string.IsNullOrEmpty(companyName.Trim()))
            {
                return(string.Empty);
            }

            companyName = companyName.Trim();
            var db = new CoreDriverContext();

            var jsonArray = new JArray();
            var videos    = db.CoreVideo.Where(v => v.CompanyName == companyName);

            foreach (var v in videos)
            {
                var json = JsonConvert.SerializeObject(v);
                jsonArray.Add(json);
            }
            db.Dispose();

            return(jsonArray.ToString());
        }
Exemple #10
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");
        }