public async Task <RepositoryResponse <PaginationModel <InfoUserViewModel> > > GetList(RequestPaging request) { Expression <Func <SiocCmsUser, bool> > predicate = model => (!request.Status.HasValue || model.Status == (int)request.Status.Value) && (string.IsNullOrWhiteSpace(request.Keyword) || ( model.Username.Contains(request.Keyword) || model.FirstName.Contains(request.Keyword) || model.LastName.Contains(request.Keyword) ) ) && (!request.FromDate.HasValue || (model.CreatedDateTime >= request.FromDate.Value.ToUniversalTime()) ) && (!request.ToDate.HasValue || (model.CreatedDateTime <= request.ToDate.Value.ToUniversalTime()) ); var data = await InfoUserViewModel.Repository.GetModelListByAsync(predicate, request.OrderBy, request.Direction, request.PageSize, request.PageIndex).ConfigureAwait(false); if (data.IsSucceed) { data.Data.Items.ForEach(a => { a.DetailsUrl = SwCmsHelper.GetRouterUrl( "Profile", new { a.Id }, Request, Url); } ); } return(data); }
public async Task <RepositoryResponse <PaginationModel <InfoArticleViewModel> > > GetList([FromBody] RequestPaging request) { ParseRequestPagingDate(request); Expression <Func <SiocArticle, bool> > predicate = model => model.Specificulture == _lang && (!request.Status.HasValue || model.Status == (int)request.Status.Value) && (string.IsNullOrWhiteSpace(request.Keyword) || ( model.Title.Contains(request.Keyword) || model.Excerpt.Contains(request.Keyword) ) ) && (!request.FromDate.HasValue || (model.CreatedDateTime >= request.FromDate.Value) ) && (!request.ToDate.HasValue || (model.CreatedDateTime <= request.ToDate.Value) ); var data = await InfoArticleViewModel.Repository.GetModelListByAsync(predicate, request.OrderBy, request.Direction, request.PageSize, request.PageIndex).ConfigureAwait(false); if (data.IsSucceed) { data.Data.Items.ForEach(a => { a.DetailsUrl = SwCmsHelper.GetRouterUrl( "Article", new { a.SeoName }, Request, Url); }); } return(data); }
public async Task <RepositoryResponse <PaginationModel <InfoCategoryViewModel> > > GetList([FromBody] RequestPaging request, int?level = 0) { string domain = string.Format("{0}://{1}", Request.Scheme, Request.Host); Expression <Func <SiocCategory, bool> > predicate = model => model.Specificulture == _lang && model.Level == level && (string.IsNullOrWhiteSpace(request.Keyword) || (model.Title.Contains(request.Keyword) || model.Excerpt.Contains(request.Keyword))) && (!request.FromDate.HasValue || (model.CreatedDateTime >= request.FromDate.Value.ToUniversalTime()) ) && (!request.ToDate.HasValue || (model.CreatedDateTime <= request.ToDate.Value.ToUniversalTime()) ) ; var data = await InfoCategoryViewModel.Repository.GetModelListByAsync(predicate, request.OrderBy, request.Direction, request.PageSize, request.PageIndex).ConfigureAwait(false); if (data.IsSucceed) { data.Data.Items.ForEach(a => { a.DetailsUrl = SwCmsHelper.GetRouterUrl( "Page", new { a.SeoName }, Request, Url); } ); } return(data); }
public async Task <JObject> BEDetails(string viewType, string id) { switch (viewType) { case "be": if (!string.IsNullOrEmpty(id)) { var beResult = await ApiArticleViewModel.Repository.GetSingleModelAsync(model => model.Id == id && model.Specificulture == _lang).ConfigureAwait(false); if (beResult.IsSucceed) { beResult.Data.DetailsUrl = SwCmsHelper.GetRouterUrl("Article", new { beResult.Data.SeoName }, Request, Url); } return(JObject.FromObject(beResult)); } else { var model = new SiocArticle() { Specificulture = _lang, Status = (int)SWStatus.Preview, Priority = ApiArticleViewModel.Repository.Max(a => a.Priority).Data + 1 }; RepositoryResponse <ApiArticleViewModel> result = new RepositoryResponse <ApiArticleViewModel>() { IsSucceed = true, Data = new ApiArticleViewModel(model) }; return(JObject.FromObject(result)); } default: if (!string.IsNullOrEmpty(id)) { var beResult = await ApiArticleViewModel.Repository.GetSingleModelAsync(model => model.Id == id && model.Specificulture == _lang).ConfigureAwait(false); if (beResult.IsSucceed) { beResult.Data.DetailsUrl = SwCmsHelper.GetRouterUrl("Article", new { beResult.Data.SeoName }, Request, Url); } return(JObject.FromObject(beResult)); } else { var model = new SiocArticle(); RepositoryResponse <ApiArticleViewModel> result = new RepositoryResponse <ApiArticleViewModel>() { IsSucceed = true, Data = new ApiArticleViewModel(model) { Specificulture = _lang, Status = SWStatus.Preview } }; return(JObject.FromObject(result)); } } }
public async Task <JObject> BEDetails(string viewType, int?id) { switch (viewType) { case "be": if (id.HasValue) { var beResult = await BECategoryViewModel.Repository.GetSingleModelAsync(model => model.Id == id && model.Specificulture == _lang).ConfigureAwait(false); if (beResult.IsSucceed) { beResult.Data.DetailsUrl = SwCmsHelper.GetRouterUrl("Page", new { beResult.Data.SeoName }, Request, Url); } return(JObject.FromObject(beResult)); } else { var model = new SiocCategory() { Specificulture = _lang, Status = (int)SWStatus.Preview }; RepositoryResponse <BECategoryViewModel> result = new RepositoryResponse <BECategoryViewModel>() { IsSucceed = true, Data = await BECategoryViewModel.InitAsync(model) }; return(JObject.FromObject(result)); } default: if (id.HasValue) { var beResult = await FECategoryViewModel.Repository.GetSingleModelAsync(model => model.Id == id && model.Specificulture == _lang).ConfigureAwait(false); if (beResult.IsSucceed) { beResult.Data.DetailsUrl = SwCmsHelper.GetRouterUrl("Page", new { beResult.Data.SeoName }, Request, Url); } return(JObject.FromObject(beResult)); } else { var model = new SiocCategory(); RepositoryResponse <FECategoryViewModel> result = new RepositoryResponse <FECategoryViewModel>() { IsSucceed = true, Data = new FECategoryViewModel(model) { Specificulture = _lang, Status = SWStatus.Preview } }; return(JObject.FromObject(result)); } } }
public async Task <RepositoryResponse <PaginationModel <InfoArticleViewModel> > > Get(int?pageSize = 15, int?pageIndex = 0, string orderBy = "Id", OrderByDirection direction = OrderByDirection.Ascending) { var data = await InfoArticleViewModel.Repository.GetModelListByAsync( m => m.Status != (int)SWStatus.Deleted && m.Specificulture == _lang, orderBy, direction, pageSize, pageIndex).ConfigureAwait(false); if (data.IsSucceed) { data.Data.Items.ForEach(a => a.DetailsUrl = SwCmsHelper.GetRouterUrl("Article", new { a.SeoName }, Request, Url)); } return(data); }
public async Task <RepositoryResponse <BEArticleViewModel> > Save([FromBody] BEArticleViewModel article) { if (article != null) { var result = await article.SaveModelAsync(true).ConfigureAwait(false); if (result.IsSucceed) { result.Data.DetailsUrl = SwCmsHelper.GetRouterUrl("Article", new { seoName = article.SeoName }, Request, Url); } return(result); } return(new RepositoryResponse <BEArticleViewModel>()); }
public async Task <RepositoryResponse <ApiArticleViewModel> > Save([FromBody] ApiArticleViewModel Article) { if (Article != null) { Article.CreatedBy = User.Identity.Name; var result = await Article.SaveModelAsync(true).ConfigureAwait(false); if (result.IsSucceed) { result.Data.DetailsUrl = SwCmsHelper.GetRouterUrl("Article", new { seoName = Article.SeoName }, Request, Url); } return(result); } return(new RepositoryResponse <ApiArticleViewModel>()); }
public async Task <RepositoryResponse <BEProductViewModel> > Save([FromBody] BEProductViewModel product) { if (product != null) { product.CreatedBy = User.Identity.Name; var result = await product.SaveModelAsync(true).ConfigureAwait(false); if (result.IsSucceed) { result.Data.DetailsUrl = SwCmsHelper.GetRouterUrl("Product", new { seoName = product.SeoName }, Request, Url); } return(result); } return(new RepositoryResponse <BEProductViewModel>()); }
public IActionResult Home(string pageName, int pageIndex, int pageSize = 10) { // Home Page if (string.IsNullOrEmpty(pageName) || pageName == "Home") { //CategoryViewModel page = CategoryRepository.GetInstance().GetFEHomeModel(p => p.Type == (int)SWCmsConstants.CateType.Home && p.Specificulture == _lang); var getPage = FECategoryViewModel.Repository.GetSingleModel(p => p.Type == (int)SWCmsConstants.CateType.Home && p.Specificulture == CurrentLanguage); if (getPage.IsSucceed && getPage.Data.View != null) { ViewBag.pageClass = getPage.Data.CssClass; return(View(getPage.Data)); } else { return(RedirectToAction("Index", "Portal", new { culture = CurrentLanguage })); } } else { var getPage = FECategoryViewModel.Repository.GetSingleModel( p => p.SeoName == pageName && p.Specificulture == CurrentLanguage); if (getPage.IsSucceed && getPage.Data.View != null) { if (getPage.Data.Type == SWCmsConstants.CateType.List) { getPage.Data.Articles.Items.ForEach(a => { a.Article.DetailsUrl = SwCmsHelper.GetRouterUrl("Article", new { a.Article.SeoName }, Request, Url); }); } if (getPage.Data.Type == SWCmsConstants.CateType.ListProduct) { getPage.Data.Products.Items.ForEach(p => { p.Product.DetailsUrl = SwCmsHelper.GetRouterUrl("Product", new { p.Product.SeoName }, Request, Url); }); } ViewBag.pageClass = getPage.Data.CssClass; return(View(getPage.Data)); } else { return(Redirect(string.Format("/{0}", CurrentLanguage))); } } }
public async Task <JObject> Details(string viewType, string id) { switch (viewType) { case "be": RepositoryResponse <ApiProductViewModel> apiResult = null; if (!string.IsNullOrEmpty(id)) { apiResult = await ApiProductViewModel.Repository.GetSingleModelAsync(model => model.Id == id && model.Specificulture == _lang).ConfigureAwait(false); if (apiResult.IsSucceed) { apiResult.Data.DetailsUrl = SwCmsHelper.GetRouterUrl("Product", new { apiResult.Data.SeoName }, Request, Url); } return(JObject.FromObject(apiResult)); } else { var model = new SiocProduct() { Specificulture = _lang, Status = GlobalConfigurationService.Instance.CmsConfigurations.DefaultStatus }; apiResult = new RepositoryResponse <ApiProductViewModel>() { IsSucceed = true, Data = new ApiProductViewModel(model) }; return(JObject.FromObject(apiResult)); } default: var result = await FEProductViewModel.Repository.GetSingleModelAsync(model => model.Id == id && model.Specificulture == _lang).ConfigureAwait(false); if (result.IsSucceed) { result.Data.DetailsUrl = SwCmsHelper.GetRouterUrl("Product", new { result.Data.SeoName }, Request, Url); } return(JObject.FromObject(result)); } }
public async Task <ActionResult <JObject> > Details(string viewType, int?id) { switch (viewType) { case "be": if (id.HasValue) { var beResult = await ApiCategoryViewModel.Repository.GetSingleModelAsync(model => model.Id == id && model.Specificulture == _lang).ConfigureAwait(false); if (beResult.IsSucceed) { beResult.Data.DetailsUrl = SwCmsHelper.GetRouterUrl("Alias", new { beResult.Data.SeoName }, Request, Url); } return(Ok(JObject.FromObject(beResult))); } else { var model = new SiocCategory() { Specificulture = _lang, Status = GlobalConfigurationService.Instance.CmsConfigurations.DefaultStatus, PageSize = 20 , Priority = ApiCategoryViewModel.Repository.Max(a => a.Priority).Data + 1 }; RepositoryResponse <ApiCategoryViewModel> result = new RepositoryResponse <ApiCategoryViewModel>() { IsSucceed = true, Data = await ApiCategoryViewModel.InitViewAsync(model) }; return(JObject.FromObject(result)); } default: if (id.HasValue) { var beResult = await FECategoryViewModel.Repository.GetSingleModelAsync(model => model.Id == id && model.Specificulture == _lang).ConfigureAwait(false); if (beResult.IsSucceed) { beResult.Data.DetailsUrl = SwCmsHelper.GetRouterUrl("Alias", new { beResult.Data.SeoName }, Request, Url); } return(JObject.FromObject(beResult)); } else { var model = new SiocCategory(); RepositoryResponse <FECategoryViewModel> result = new RepositoryResponse <FECategoryViewModel>() { IsSucceed = true, Data = new FECategoryViewModel(model) { Specificulture = _lang, Status = SWStatus.Preview, PageSize = 20 } }; return(JObject.FromObject(result)); } } }
public async Task <JObject> GetList( [FromBody] RequestPaging request, int?level = 0) { ParseRequestPagingDate(request); Expression <Func <SiocCategory, bool> > predicate = model => model.Specificulture == _lang && (!request.Status.HasValue || model.Status == request.Status.Value) && (!level.HasValue || model.Level == level) && (string.IsNullOrWhiteSpace(request.Keyword) || (model.Title.Contains(request.Keyword) || model.Excerpt.Contains(request.Keyword))) && (!request.FromDate.HasValue || (model.CreatedDateTime >= request.FromDate.Value) ) && (!request.ToDate.HasValue || (model.CreatedDateTime <= request.ToDate.Value) ); switch (request.Key) { case "fe": var fedata = await FECategoryViewModel.Repository.GetModelListByAsync(predicate, request.OrderBy, request.Direction, request.PageSize, request.PageIndex).ConfigureAwait(false); if (fedata.IsSucceed) { fedata.Data.Items.ForEach(a => { a.DetailsUrl = SwCmsHelper.GetRouterUrl( "Alias", new { seoName = a.UrlAlias.Alias }, Request, Url); }); } return(JObject.FromObject(fedata)); case "be": var bedata = await ApiCategoryViewModel.Repository.GetModelListByAsync(predicate, request.OrderBy, request.Direction, request.PageSize, request.PageIndex).ConfigureAwait(false); if (bedata.IsSucceed) { bedata.Data.Items.ForEach(a => { a.DetailsUrl = SwCmsHelper.GetRouterUrl( "Alias", new { seoName = a.UrlAlias.Alias }, Request, Url); }); } return(JObject.FromObject(bedata)); default: var data = await InfoCategoryViewModel.Repository.GetModelListByAsync(predicate, request.OrderBy, request.Direction, request.PageSize, request.PageIndex).ConfigureAwait(false); if (data.IsSucceed) { data.Data.Items.ForEach((Action <InfoCategoryViewModel>)(a => { a.DetailsUrl = SwCmsHelper.GetRouterUrl( "Alias", new { seoName = a.UrlAlias.Alias }, Request, Url); a.Childs.ForEach((Action <InfoCategoryViewModel>)(c => { c.DetailsUrl = SwCmsHelper.GetRouterUrl( "Alias", new { seoName = c.UrlAlias.Alias }, Request, Url); })); })); } return(JObject.FromObject(data)); } }
string GenerateDetailsUrl(string type, object routeValues) { return(SwCmsHelper.GetRouterUrl(type, routeValues, Request, Url)); }