public ActionResult NewSentence(string body, string mean, Guid wordUN) { IWord iword = new BsWord(); //kelime var mı kontrol et.varsa ekleme. EWSSampleSentence sent = iword.GetSampleSentenceByBody(body); if (sent != null) { return(Script("Message('Bu cümle zaten ekli.','info');")); } EWSSampleSentence sentence = new EWSSampleSentence() { UN = Guid.NewGuid(), Sentence = body, SentenceMean = mean, UserID = GetCurrentUser().ID, WordUN = wordUN, }; iword.SaveSampleSentence(sentence); return(Script("Message('Cümle Eklendi','success');")); }
public void DeleteComment(Guid ID) { RepositoryBase <EWSSampleSentence> _rep = new RepositoryBase <EWSSampleSentence>(); EWSSampleSentence samp = _rep.Get(p => p.UN == ID); _rep.Remove(samp); }
public EWSSampleSentence GetSentenceByBody(string sentence) { IRepositoryBase <EWSSampleSentence> _repSentence = new RepositoryBase <EWSSampleSentence>(); EWSSampleSentence _sentence = _repSentence.Get(p => p.Sentence == sentence); return(_sentence); }
public EWSSampleSentence GetSentenceById(Guid Id) { IRepositoryBase <EWSSampleSentence> _repSentence = new RepositoryBase <EWSSampleSentence>(); EWSSampleSentence sentence = _repSentence.Get(p => p.UN == Id); return(sentence); }
public ActionResult DeleteRelationSentenceAndWord(Guid UN) { ISentence isentence = new BSSentence(); EWSSampleSentence sentence = isentence.GetSentenceById(UN); sentence.WordUN = null; isentence.DeleteReletaionSentenceWord(sentence); return(Script("Message('Kelime ile cümle ilişki kaldırıldı','success');")); }
public void DeleteReletaionSentenceWord(EWSSampleSentence _sentence) { IRepositoryBase <EWSSampleSentence> _repSentence = new RepositoryBase <EWSSampleSentence>(); EWSSampleSentence sentence = _repSentence.Get(p => p.UN == _sentence.UN); if (sentence != null) { sentence.WordUN = _sentence.WordUN; } _repSentence.Update(sentence); }
public EWSSampleSentence SaveSentence(EWSSampleSentence _sentence) { IRepositoryBase <EWSSampleSentence> _repSentence = new RepositoryBase <EWSSampleSentence>(); EWSSampleSentence sentence = new EWSSampleSentence(); sentence.UN = _sentence.UN; sentence.Sentence = _sentence.Sentence; sentence.SentenceMean = _sentence.SentenceMean; _repSentence.Add(sentence); return(sentence); }
public void UpdateSentence(EWSSampleSentence _sentence) { IRepositoryBase <EWSSampleSentence> _repSentence = new RepositoryBase <EWSSampleSentence>(); EWSSampleSentence sentence = _repSentence.Get(p => p.UN == _sentence.UN); if (sentence != null) { sentence.Sentence = _sentence.Sentence; sentence.SentenceMean = _sentence.SentenceMean; sentence.WordUN = _sentence.WordUN; } _repSentence.Update(sentence); }
public ActionResult SaveComment(Guid wordID, string comment, string commentMean) { IWord iword = new BsWord(); EWSSampleSentence ewsSamp = new EWSSampleSentence() { Sentence = comment, UN = Guid.NewGuid(), UserID = GetCurrentUser().ID, WordUN = wordID, SentenceMean = commentMean, }; iword.SaveComment(ewsSamp); return(GetWordSamples(wordID)); }
public ActionResult UpdateSentence(Guid UN, string sentenceBody, string sentenceMean) { ISentence isentence = new BSSentence(); EWSSampleSentence sentence = new EWSSampleSentence() { UN = UN, Sentence = sentenceBody, SentenceMean = sentenceMean, UserID = GetCurrentUser().ID, }; isentence.UpdateSentence(sentence); return(Script("Message('Cümle Kayıt Edildi.','success');")); }
public ActionResult NewSentence(string sentenceBody, string sentenceMean) { ISentence isentence = new BSSentence(); ViewBag.Title = "New Word"; EWSSampleSentence sentence = new EWSSampleSentence() { UN = Guid.NewGuid(), Sentence = sentenceBody, SentenceMean = sentenceMean, UserID = GetCurrentUser().ID, }; sentence = isentence.SaveSentence(sentence); return(Script("Message('Cümle Kayıt Edildi.','success');")); }
public ActionResult SaveSentence(string sentenceBody, string sentenceMean) { ISentence isentence = new BSSentence(); ViewBag.Title = "New Sentence"; EWSSampleSentence sentence = isentence.GetSentenceByBody(sentenceBody); if (sentence != null) { sentence.SentenceMean = sentenceBody; sentence.SentenceMean = sentenceMean; isentence.SaveSentence(sentence); ViewBag.Message = "Cümle zaten vardı güncellendi."; ViewBag.MessageType = "info"; return(PartialView("WordSave")); } if (sentence == null) { sentence = new EWSSampleSentence() { UN = Guid.NewGuid(), Sentence = sentenceBody, SentenceMean = sentenceMean, UserID = GetCurrentUser().ID, } } ; isentence.SaveSentence(sentence); ViewBag.Message = "Cümle Kayıt Edildi"; ViewBag.MessageType = "success"; return(PartialView("WordSave")); }
public EWSSampleSentence SaveSampleSentence(EWSSampleSentence sentence) { IRepositoryBase <EWSSampleSentence> _rep = new RepositoryBase <EWSSampleSentence>(); return(_rep.Add(sentence)); }
public void SaveWordMultiple(List <EWSWord> listOfWord, string listName, int userID) { IRepositoryBase <EWSWord> _rep = new RepositoryBase <EWSWord>(); IRepositoryBase <EWSSampleSentence> _repSamp = new RepositoryBase <EWSSampleSentence>(); IRepositoryBase <EWSList> _repList = new RepositoryBase <EWSList>(); IRepositoryBase <EWSListWord> _repListWord = new RepositoryBase <EWSListWord>(); string lName = ""; if (listName.Contains(".")) { string[] preFileName = listName.Split('.'); if (preFileName != null && preFileName.Count() > 0) { lName = preFileName[0]; } } else { lName = listName; } if (listOfWord == null || listOfWord.Count == 0) { return; } List <EWSWord> wordList = new List <EWSWord>(); EWSList list = new EWSList() { UN = Guid.NewGuid(), Name = lName, UserID = userID, }; if (userID == 1) { list.UserID = null; } list = _repList.Add(list); Translator t = new Translator(); foreach (var item in listOfWord) { EWSWord w = _rep.Get(p => p.WordBody == item.WordBody); if (w == null) { if (item.WordBody != null || item.Description == "") { string TranslateText = item.WordBody.Trim(); string result = t.Translate(TranslateText, "English", "Turkish"); item.Description = result; } w = new EWSWord() { UN = Guid.NewGuid(), WordBody = item.WordBody, UserID = userID, Description = item.Description }; w = _rep.Add(w); wordList.Add(w); foreach (var itemSamp in item.EWSSampleSentence) { if (itemSamp.Sentence != "" && itemSamp.SentenceMean == "") { itemSamp.Sentence = itemSamp.Sentence.Replace("\\n", ""); itemSamp.Sentence = itemSamp.Sentence.Replace("\\r", ""); string TranslateText = itemSamp.Sentence.Trim(); string result = t.Translate(TranslateText, "English", "Turkish"); itemSamp.SentenceMean = result; } EWSSampleSentence samp = new EWSSampleSentence() { Sentence = itemSamp.Sentence, UserID = itemSamp.UserID, SentenceMean = itemSamp.SentenceMean, UN = Guid.NewGuid(), WordUN = w.UN, }; _repSamp.Add(samp); } } else if (item.EWSSampleSentence != null) { wordList.Add(w); foreach (var itemSamp in item.EWSSampleSentence) { EWSSampleSentence samp = new EWSSampleSentence() { Sentence = itemSamp.Sentence, UserID = itemSamp.UserID, SentenceMean = itemSamp.SentenceMean, UN = Guid.NewGuid(), WordUN = w.UN, }; _repSamp.Add(samp); } } } foreach (var item in wordList) { EWSListWord listWrd = _repListWord.Get(p => p.WordUN == item.UN && p.ListUN == list.UN); if (listWrd != null) { continue; } listWrd = new EWSListWord() { UN = Guid.NewGuid(), WordUN = item.UN, ListUN = list.UN, isPublic = false, }; _repListWord.Add(listWrd); } }
public EWSSampleSentence SaveComment(EWSSampleSentence ewsSample) { RepositoryBase <EWSSampleSentence> _rep = new RepositoryBase <EWSSampleSentence>(); return(_rep.Add(ewsSample)); }
public ActionResult UploadListWithFile() { if (Request.Files.Count > 0) { HttpFileCollectionBase files = Request.Files; string filename = Path.GetFileName(Request.Files[0].FileName); HttpPostedFileBase file = files[0]; string fname; if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { fname = file.FileName; } List <EWSWord> listOfWord = new List <EWSWord>(); if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName)) { string fileName = file.FileName; string fileContentType = file.ContentType; byte[] fileBytes = new byte[file.ContentLength]; var data = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength)); using (var package = new ExcelPackage(file.InputStream)) { var currentSheet = package.Workbook.Worksheets; ExcelWorksheet workSheet = currentSheet.First(); var noOfCol = workSheet.Dimension.End.Column; var noOfRow = workSheet.Dimension.End.Row; string word; string mean; string sampleSentence; string sampleSentenceMean; for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++) { word = (workSheet.Cells[rowIterator, 1].Value == null) ? "" : workSheet.Cells[rowIterator, 1].Value.ToString(); mean = ((workSheet.Cells[rowIterator, 2].Value == null) ? "" : workSheet.Cells[rowIterator, 2].Value.ToString()); sampleSentence = ((workSheet.Cells[rowIterator, 3].Value == null) ? "" : workSheet.Cells[rowIterator, 3].Value.ToString()); sampleSentenceMean = ((workSheet.Cells[rowIterator, 4].Value == null) ? "" : workSheet.Cells[rowIterator, 4].Value.ToString()); EWSWord w = new EWSWord(); w.WordBody = word.ToLowerInvariant(); w.Description = mean.ToLowerInvariant(); w.UserID = GetCurrentUser().ID; if (sampleSentence != "") { EWSSampleSentence sentence = new EWSSampleSentence() { UN = Guid.NewGuid(), UserID = GetCurrentUser().ID, Sentence = sampleSentence, SentenceMean = sampleSentenceMean, }; w.EWSSampleSentence.Add(sentence); } listOfWord.Add(w); } // for end } //using end } //if end IWord iWord = new BsWord(); iWord.SaveWordMultiple(listOfWord, fname, GetCurrentUser().ID); } return(Content("")); }