示例#1
0
        public CatalogFunctionModel Insert(string userCurrentId, CatalogFunctionModel catalogFunction)
        {
            try
            {
                var newCat = _mapper.Map <CatalogFunction>(catalogFunction);

                newCat.CreatedBy = userCurrentId;
                newCat.Slug      = StringHelper.ToUrlFriendly(catalogFunction.Name);

                _catalogFunctionRepo.Insert(newCat);

                var newSearchPage = new SearchPage();
                newSearchPage.Lang   = newCat.Lang;
                newSearchPage.Name   = newCat.Name;
                newSearchPage.Slug   = newCat.Slug;
                newSearchPage.ItemId = newCat.Id;

                if (newCat.Lang == Languages.Vi)
                {
                    newSearchPage.URL = CatalogEndpoints.FunctionEndpoint.Replace("{function}", newSearchPage.Slug);
                }
                else
                {
                    newSearchPage.URL = CatalogEndpoints.EnglishFunctionEndpoint.Replace("{function}", newSearchPage.Slug);
                }

                _searchPageRepo.Insert(newSearchPage);

                return(catalogFunction);
            }
            catch
            {
                throw;
            }
        }
示例#2
0
 public IActionResult Update(string id, CatalogFunctionModel catModel)
 {
     if (ModelState.IsValid)
     {
         var updateCat = _catalogFunctionService.Update(id, base.UserId, catModel);
     }
     return(Ok());
 }
示例#3
0
 public IActionResult Create(CatalogFunctionModel catModel)
 {
     if (ModelState.IsValid)
     {
         var newCat = _catalogFunctionService.Insert(base.UserId, catModel);
     }
     return(Ok());
 }
示例#4
0
        public CatalogFunctionModel Update(string catId, string userCurrentId, CatalogFunctionModel catalogFunction)
        {
            try
            {
                var updateCat = _catalogFunctionRepo.GetById(catId);

                _mapper.Map(catalogFunction, updateCat);

                updateCat.LastUpdatedBy = userCurrentId;
                updateCat.Slug          = StringHelper.ToUrlFriendly(catalogFunction.Name);

                _catalogFunctionRepo.Update(updateCat);

                var updateSearch = _searchPageRepo.TableNoTracking.FirstOrDefault(x => x.ItemId == catId);

                if (updateSearch != null)
                {
                    updateSearch.Slug = updateCat.Slug;
                    updateSearch.Lang = updateCat.Lang;
                    updateSearch.Name = updateCat.Name;
                }


                if (updateCat.Lang == Languages.Vi)
                {
                    updateSearch.URL = CatalogEndpoints.FunctionEndpoint.Replace("{function}", updateSearch.Slug);
                }
                else
                {
                    updateSearch.URL = CatalogEndpoints.EnglishFunctionEndpoint.Replace("{function}", updateSearch.Slug);
                }

                _searchPageRepo.Update(updateSearch);

                return(catalogFunction);
            }
            catch
            {
                throw;
            }
        }