示例#1
0
        public ResultModel Delete(int Id)
        {
            ResultModel oOutput = new ResultModel();

            try
            {
                Dictonarytb oReoord = dbSet.Where(m => m.ID == Id).FirstOrDefault();
                if (oReoord != null)
                {
                    DictonaryLanguage oDictonaryLanguage = oDB.DictonaryLanguage.Where(s => s.DictonarytbID == Id).FirstOrDefault();
                    if (oDictonaryLanguage != null)
                    {
                        oDB.DictonaryLanguage.Remove(oDictonaryLanguage);
                    }
                    DictonarySource oDictonarySource = oDB.DictonarySource.Where(s => s.DictonarytbID == Id).FirstOrDefault();
                    if (oDictonarySource != null)
                    {
                        oDB.DictonarySource.Remove(oDictonarySource);
                    }
                    dbSet.Remove(oReoord);
                    oDB.SaveChanges();
                    oOutput.Status = 1;
                    oOutput.Msg    = "done";
                }
            }
            catch (Exception ex)
            {
                oOutput.Status = 0;
                oOutput.Msg    = "Data access error";
                Services.Utitilty.Error(ex);
            }
            return(oOutput);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }