public bool Save(string version, int actress) { using (SekaiAVDataDataContext db = new SekaiAVDataDataContext()) { var count = (from m in db.t_video where m.f_javlib_id == this.JL_Id select m).Count(); t_video entry; if (count == 0) { entry = new t_video() { f_code = this.Code, f_issuer_date = this.IssueDate, f_javlib_id = this.JL_Id, f_length = this.Length, f_name = this.Name, f_update = DateTime.Now, f_version = version }; if (this.Factory != null) { entry.f_factory = this.Factory.Id; } else { entry.f_factory = -1; } if (this.Issuer != null) { entry.f_issuer = this.Issuer.Id; } else { entry.f_issuer = -1; } if (this.Director != null) { entry.f_director = this.Director.Id; } else { entry.f_director = -1; } db.t_video.InsertOnSubmit(entry); db.SubmitChanges(); var rcount = (from m in db.t_actress_video where m.f_actress == actress && m.f_video == entry.id select m).Count(); if (rcount == 0) { db.t_actress_video.InsertOnSubmit(new t_actress_video() { f_actress = actress, f_video = entry.id }); db.SubmitChanges(); } } else { entry = (from m in db.t_video where m.f_javlib_id == this.JL_Id select m).First(); entry.f_code = this.Code; entry.f_issuer_date = this.IssueDate; entry.f_javlib_id = this.JL_Id; entry.f_length = this.Length; entry.f_name = this.Name; entry.f_update = DateTime.Now; entry.f_version = version; if (this.Factory != null) { entry.f_factory = this.Factory.Id; } else { entry.f_factory = -1; } if (this.Issuer != null) { entry.f_issuer = this.Issuer.Id; } else { entry.f_issuer = -1; } if (this.Director != null) { entry.f_director = this.Director.Id; } else { entry.f_director = -1; } db.SubmitChanges(); var rcount = (from m in db.t_actress_video where m.f_actress == actress && m.f_video == entry.id select m).Count(); if (rcount == 0) { db.t_actress_video.InsertOnSubmit(new t_actress_video() { f_actress = actress, f_video = entry.id }); db.SubmitChanges(); } } } return true; }
partial void Updatet_video(t_video instance);
partial void Deletet_video(t_video instance);
partial void Insertt_video(t_video instance);