public long Add(DicInfo model) { model.Id = IdHelper.GetNewId(); if (AutofacConfig.Resolve <DicInfoRepository>().Add(model) > 0) { return(model.Id); } return(0); }
public ActionResult Create(WordVars model, [Deserialize] DicInfo info) { var dic = unitOfWork.DictionaryRepository.GetByID(info.id); Word word = new Word(); if (model.WId == null) { if (unitOfWork.WordRepository.Get(d => d.word == model.word).Count() > 0) { throw new JsonCustomException(model.lang == lang.en ? ControllerError.ajaxErrorWordDuplicateEn : ControllerError.ajaxErrorWordDuplicateFa); } word.lang = model.lang; word.word = model.word; word.date = DateTime.UtcNow; word.creatorId = WebSecurity.CurrentUserId; WordDesc enWordDesc = new WordDesc(); enWordDesc.dicId = info.id; enWordDesc.desc = model.wordDesc; enWordDesc.date = DateTime.UtcNow; enWordDesc.creatorId = WebSecurity.CurrentUserId; if (word.Descs == null) { word.Descs = new List <WordDesc>(); } word.Descs.Add(enWordDesc); unitOfWork.WordRepository.Insert(word); } else { word = unitOfWork.WordRepository.GetByID(model.WId); if (!word.Descs.Any(d => d.dicId == info.id)) { WordDesc enWordDesc = new WordDesc(); enWordDesc.dicId = info.id; enWordDesc.desc = model.wordDesc; enWordDesc.date = DateTime.UtcNow; enWordDesc.creatorId = WebSecurity.CurrentUserId; if (word.Descs == null) { word.Descs = new List <WordDesc>(); } word.Descs.Add(enWordDesc); } unitOfWork.WordRepository.Update(word); } unitOfWork.Save(); return(Json(new { Url = Url.Action("AddTranslate", "Word", new { WId = word.wordId, DId = dic.dicId }) })); }
public ActionResult Create(int DId) { var dic = unitOfWork.DictionaryRepository.GetByID(DId); DicInfo dinfo = new DicInfo { name = dic.name, id = dic.dicId }; WordVars model = new WordVars { dicInfo = dinfo }; return(View(model)); }
public ActionResult AddTranslate(int DId, int WId) { var dic = unitOfWork.DictionaryRepository.GetByID(DId); var word = unitOfWork.WordRepository.GetByID(WId); DicInfo dinfo = new DicInfo { name = dic.name, id = dic.dicId, mainWid = word.wordId }; WordTranslateVars model = new WordTranslateVars { mainWord = word, dicInfo = dinfo }; return(View(model)); }
public ActionResult Edit(int WId, int DId) { var reader = unitOfWork.ReaderRepository.GetSPDataReader( "WordAndEdits", new SqlParameter("DId", DId), new SqlParameter("WId", WId), new SqlParameter("isNotEN", ITTConfig.CurrentCultureIsNotEN)); WordEditVars model = new WordEditVars(); if (reader.Read()) { var dicInfo = new DicInfo { name = reader[3] as string }; model = new WordEditVars { DId = DId, mainWId = reader.GetInt32(0), word = reader[1] as string, lang = (lang)reader.GetInt32(2), dicInfo = dicInfo }; } reader.NextResult(); model.wordEditgs = new List <WordEditwithScore>(); while (reader.Read()) { model.wordEditgs.Add(new WordEditwithScore { editId = reader.GetInt32(0), sugWordId = reader[1] as int?, text = reader[2] as string, editorId = reader.GetInt32(3), date = reader.GetDateTime(4), editorName = reader[5] as string, editorIMage = reader[6] as string, Score = reader[7] as int? }); } return(View(model)); }
public bool Update(DicInfo model) { return(AutofacConfig.Resolve <DicInfoRepository>().Update(model) > 0); }