Пример #1
0
        public static ApiResponse GetByCode(string code)
        {
            var result = new ApiResponse();

            try
            {
                var languages = BlAppLanguage.GetAll();
                var list      = new List <DeNews>();
                foreach (var item in languages)
                {
                    var obj = new DlNews().GetAll().FirstOrDefault(x => x.NewsCode == code && x.LangCode == item.LangCode);
                    if (obj != null)
                    {
                        list.Add(obj);
                    }
                    else
                    {
                        list.Add(new DeNews {
                            NewsCode = code, NewsTitle = "", NewsContent = "", LangCode = item.LangCode
                        });
                    }
                }

                result = new ApiResponse(true, "", list);
            }
            catch (Exception ex)
            {
                result = new ApiResponse(false, ex.Message, null);
            }
            return(result);
        }
Пример #2
0
        public static ApiResponse GetRecipeAllLanguages(string id)
        {
            var result = new ApiResponse();

            try
            {
                var languages = BlAppLanguage.GetAll();
                var list      = new List <DeRecipe>();
                foreach (var item in languages)
                {
                    var obj = new DlRecipe().GetAll().FirstOrDefault(x => x.RecipeCode == id && x.LangCode == item.LangCode);
                    if (obj != null)
                    {
                        list.Add(obj);
                    }
                    else
                    {
                        list.Add(new DeRecipe {
                            RecipeCode = id, RecipeTitle = "", RecipeContent = "", LangCode = item.LangCode
                        });
                    }
                }
                result = new ApiResponse(true, "", list);
            }
            catch (Exception ex)
            {
                result = new ApiResponse(false, ex.Message, null);
            }
            return(result);
        }
Пример #3
0
        public static ApiResponse GetByCode(string id)
        {
            var result = new ApiResponse();

            try
            {
                var languages = BlAppLanguage.GetAll();
                var list      = new List <DeFood>();
                foreach (var item in languages)
                {
                    var obj = new DlFood().GetAll().FirstOrDefault(x => x.FoodCode == id && x.LangCode == item.LangCode);
                    if (obj != null)
                    {
                        list.Add(obj);
                    }
                    else
                    {
                        list.Add(new DeFood {
                            FoodCode = id, FoodTitle = "", FoodContent = "", FoodGroupID = 1, LangCode = item.LangCode
                        });
                    }
                }
                result = new ApiResponse(true, "", list);
            }
            catch (Exception ex)
            {
                result = new ApiResponse(false, ex.Message, null);
            }
            return(result);
        }
Пример #4
0
        public static ApiResponse GetInfoByCode(string code)
        {
            var result = new ApiResponse();
            var dl     = new DlAppInfo();

            try
            {
                var languages = BlAppLanguage.GetAll();
                var list      = new List <DeAppInfo>();
                foreach (var item in languages)
                {
                    var obj = dl.GetAll().FirstOrDefault(x => x.InfoCode == code && x.LangCode == item.LangCode);
                    if (obj != null)
                    {
                        list.Add(obj);
                    }
                    else
                    {
                        list.Add(new DeAppInfo {
                            InfoCode = code, InfoContent = "", LangCode = item.LangCode
                        });
                    }
                }
                result = new ApiResponse()
                {
                    Success = true, Payload = list
                };
            }
            catch (Exception ex)
            {
                result = new ApiResponse()
                {
                    Success = false, Payload = null, Message = ex.Message
                };
            }
            return(result);
        }