public ResultModel Insert(DictonaryModel obj) { ResultModel oOutput = new ResultModel(); try { Dictonarytb oDictonary = Mapper.Map <Dictonarytb>(obj); dbSet.Add(oDictonary); oDB.SaveChanges(); } catch (Exception ex) { oOutput.Status = 0; oOutput.Msg = "Data access error"; Services.Utitilty.Error(ex); } return(oOutput); }
public ResultModel GetById(int Id) { ResultModel oOutput = new ResultModel(); try { DictonaryModel oDictonaryModel = Mapper.Map <DictonaryModel>(dbSet.Include("DictonaryLanguage").Include("DictonarySource").Where(m => m.ID == Id).FirstOrDefault()); List <Source> oSource = oDB.Source.ToList(); List <Language> oLanguage = oDB.Language.ToList(); if (oDictonaryModel.DictonarySource != null && oSource.Count > 0) { foreach (var item in oDictonaryModel.DictonarySource) { if (item.SourceID != null && item.SourceID > 0) { item.SourceName = oSource.Where(s => s.ID == item.SourceID).FirstOrDefault().SourceName; } if (item.LanguageID != null && oLanguage.Count > 0) { item.LanguageName = oLanguage.Where(s => s.ID == item.LanguageID).FirstOrDefault().LanguageName; } } } if (oDictonaryModel.DictonaryLanguage != null && oLanguage.Count > 0) { foreach (var item in oDictonaryModel.DictonaryLanguage) { if (item.LanguageID != null) { item.LanguageName = oLanguage.Where(s => s.ID == item.LanguageID).FirstOrDefault().LanguageName; } } } oOutput.Data = oDictonaryModel; } catch (Exception ex) { oOutput.Status = 0; oOutput.Msg = "Data access error"; Services.Utitilty.Error(ex); } return(oOutput); }
public ResultModel Update(DictonaryModel obj) { ResultModel oOutput = new ResultModel(); try { Dictonarytb oDictonary = dbSet.Where(m => m.ID == obj.ID).FirstOrDefault(); if (oDictonary == null) { oOutput.Status = 0; oOutput.Msg = "Record not exist"; } else { List <DictonaryLanguage> oDictonaryLanguage = oDB.DictonaryLanguage.Where(s => s.DictonarytbID == obj.ID).ToList(); if (oDictonaryLanguage != null) { oDB.DictonaryLanguage.RemoveRange(oDictonaryLanguage); oDB.SaveChanges(); } List <DictonarySource> oDictonarySource = oDB.DictonarySource.Where(s => s.DictonarytbID == obj.ID).ToList(); if (oDictonarySource != null) { oDB.DictonarySource.RemoveRange(oDictonarySource); oDB.SaveChanges(); } oDictonary = Mapper.Map(obj, oDictonary); oDB.SaveChanges(); } oOutput.Data = oDictonary; } catch (Exception ex) { oOutput.Status = 0; oOutput.Msg = "Data access error"; Services.Utitilty.Error(ex); } return(oOutput); }
public ResultModel Put([FromBody] DictonaryModel obj) { return(_svr.Update(obj)); }
public ResultModel Post([FromBody] DictonaryModel obj) { return(_svr.Insert(obj)); }