public ActionResult GetCatalog([FromRoute] decimal cd, [FromRoute] string language) { M_CATALOG catalog = _context.M_CATALOGS.FirstOrDefault(x => x.CATALOG_CD == cd); if (catalog == null) { return(Ok(new Result { Status = 404, Message = "Data not exists.", Data = null })); } CatalogEntity entity = new CatalogEntity(); entity.cd = catalog.CATALOG_CD; if (string.IsNullOrEmpty(language) || language.Equals(Constant.LANGUAGE_VN)) { entity.name = catalog.CATALOG_NAME; } else { entity.name = catalog.CATALOG_NAME_EN; } return(Ok(new Result { Status = 200, Message = string.Empty, Data = entity })); }
/// <summary> /// Get catalog name. /// </summary> /// <param name="languageType">Language type</param> /// <param name="cd">Catalog cd</param> /// <returns></returns> public static string GetCatalogName(AloaiDataContext db, string languageType, decimal?cd) { string name = string.Empty; var query = from d in db.M_CATALOGS where d.CATALOG_CD == cd select d; if (query.Any()) { M_CATALOG catalog = query.Single(); if (string.IsNullOrEmpty(languageType) || languageType.Equals(Constant.LANGUAGE_VN)) { name = catalog.CATALOG_NAME; } else { name = catalog.CATALOG_NAME_EN; } } return(name); }