Esempio n. 1
0
        public virtual async Task <Store[]> GetByIdsAsync(string[] ids)
        {
            var cacheKey = CacheKey.With(GetType(), "GetByIdsAsync", string.Join("-", ids));

            return(await PlatformMemoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) =>
            {
                var stores = new List <Store>();

                using (var repository = RepositoryFactory())
                {
                    repository.DisableChangesTracking();

                    var dbStores = await repository.GetStoresByIdsAsync(ids);
                    foreach (var dbStore in dbStores)
                    {
                        var store = AbstractTypeFactory <Store> .TryCreateInstance();
                        dbStore.ToModel(store);

                        PopulateStore(store, dbStore);

                        await SettingManager.DeepLoadSettingsAsync(store);
                        stores.Add(store);
                        cacheEntry.AddExpirationToken(StoreCacheRegion.CreateChangeToken(store));
                    }
                }

                var result = stores.ToArray();
                var taskLoadDynamicPropertyValues = DynamicPropertyService.LoadDynamicPropertyValuesAsync(result);
                var taskLoadSeoForObjects = SeoService.LoadSeoForObjectsAsync(result);
                await Task.WhenAll(taskLoadDynamicPropertyValues, taskLoadSeoForObjects);

                return result;
            }));
        }
Esempio n. 2
0
        public ActionResult Edit(CategoryViewModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                Picture pic = new Picture();

                InsertPicture(pic, model);

                Category cat = new Category();
                cat.Id          = model.Id;
                cat.Name        = model.Name;
                cat.Seo         = SeoService.ToSeoUrl(model.Name);
                cat.Description = model.Description;
                cat.ParantId    = model.ParantId ?? 0;
                if (pic.Id > 0)
                {
                    cat.PictureId = pic.Id;
                }
                else
                {
                    cat.PictureId = model.PictureId;
                }
                cat.Published   = model.Published;
                cat.OrderNo     = model.OrderNo;
                cat.UpdatedDate = DateTime.Now;
                cat.UpdatedById = 1;
                cat.CreatedById = model.CreatedById;
                cat.CreatedDate = model.CreatedDate;
                cat.IsActive    = true;
                cat.IsDeleted   = false;
                if (pic.Id > 0)
                {
                    cat.PictureId = pic.Id;
                }
                if (_categoryService.Update(cat) == true)
                {
                    Success("Güncelleme işlemi Başarılı");
                }
                else
                {
                    Danger("Güncelleme işlemi Başarısız");
                }
                if (continueEditing)
                {
                    return(RedirectToAction("Edit", "Category", new { id = model.Id }));
                }
                else
                {
                    return(RedirectToAction("List", "Category"));
                }
            }
            model.CategoryList = GetCategoryDropList();

            return(View(model));
        }
Esempio n. 3
0
        //
        // GET: /Home/

        public HomeController(BusinessFactory business, IRouteManager routeManager, ModuleManager moduleManager,
                              GetSeoCommand getSeoCommand, SeoService seoService, ResetSiteCacheCommand resetSiteCacheCommand,
                              IOptions <ApplicationConfig> options, ILogger <HomeController> logger)
            : base(business)
        {
            _routeManager          = routeManager;
            _moduleManager         = moduleManager;
            _seoService            = seoService;
            _resetSiteCacheCommand = resetSiteCacheCommand;
            _logger            = logger;
            _applicationConfig = options.Value;
            _getSeoCommand     = getSeoCommand;
        }
Esempio n. 4
0
        public ActionResult Edit(BrandViewModel model, bool continueEditing)
        {
            Brand   _brand = new Brand();
            Picture _pic   = new Picture();

            if (ModelState.IsValid)
            {
                InsertPicture(_pic, model);

                _brand.Id          = model.Id;
                _brand.Name        = model.Name;
                _brand.Description = model.Description;
                _brand.OrderNo     = model.OrderNo;
                _brand.Seo         = SeoService.ToSeoUrl(model.Name);
                _brand.CreatedById = model.CreatedById;
                _brand.CreatedDate = model.CreatedDate;
                _brand.UpdatedById = 1;
                _brand.UpdatedDate = DateTime.Now;
                _brand.IsActive    = true;
                _brand.IsDeleted   = false;
                if (_pic.Id > 0)
                {
                    _brand.PictureId = _pic.Id;
                }
                else
                {
                    _brand.PictureId = model.PictureId;
                }
                if (_brandservice.Update(_brand))
                {
                    Success("Güncelleme işlemi başarılı bir şekilde gerçekleşti");
                }
                else
                {
                    Danger("Guncelleme işlemi sırasında bir hata oluştu");
                }
                if (continueEditing)
                {
                    return(RedirectToAction("Edit", "Brand", new { id = _brand.Id }));
                }

                return(RedirectToAction("List", "Brand"));
            }
            return(View(model));
        }
Esempio n. 5
0
        public ActionResult Create(BrandViewModel model, bool continueEditing)
        {
            Brand   _brand = new Brand();
            Picture _pic   = new Picture();

            if (ModelState.IsValid)
            {
                InsertPicture(_pic, model);

                //var data = QMapper.CloneClassicVersion(model, typeof(Brand)) as Brand;

                _brand.Name        = model.Name;
                _brand.Description = model.Description;
                _brand.OrderNo     = model.OrderNo;
                _brand.Seo         = SeoService.ToSeoUrl(model.Name);
                _brand.CreatedById = 1;
                _brand.CreatedDate = DateTime.Now;
                _brand.IsActive    = true;
                _brand.IsDeleted   = false;
                if (_pic.Id > 0)
                {
                    _brand.PictureId = _pic.Id;
                }
                if (_brandservice.Insert(_brand) != null)
                {
                    Success("Kayit işlemi başarılı bir şekilde gerçekleşti");
                }
                else
                {
                    Danger("Kayit işlemi sırasında problem oluştu");
                }


                if (continueEditing)
                {
                    return(RedirectToAction("Edit", "Brand", new { id = _brand.Id }));
                }
                else
                {
                    return(RedirectToAction("List", "Brand"));
                }
            }
            return(View(model));
        }
Esempio n. 6
0
        public ActionResult Create(ProductViewModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                Product _pro = new Product();
                _pro.Name             = model.Name;
                _pro.ShortDescription = model.ShortDescription;
                _pro.LongDescription  = model.LongDescription;
                _pro.Seo             = SeoService.ToSeoUrl(model.Name);
                _pro.BrandId         = model.BrandId;
                _pro.OldPrice        = model.OldPrice;
                _pro.Price           = model.Price;
                _pro.ProductCost     = model.ProductCost;
                _pro.Qunatity        = model.Qunatity;
                _pro.Sku             = model.Sku;
                _pro.Vat             = model.Vat;
                _pro.ShowOnHomePage  = model.ShowOnHomePage;
                _pro.Published       = model.Published;
                _pro.IsFreeShipping  = model.IsFreeShipping;
                _pro.MetaDescription = model.MetaDescription;
                _pro.MetaKeywords    = model.MetaKeywords;
                _pro.MetaTitle       = model.MetaTitle;
                if (_productService.Insert(_pro) != null)
                {
                    ProdutTagMappingUpdateInsert(model.ProductTags, _pro.Id);


                    if (continueEditing)
                    {
                        return(RedirectToAction("Edit", "Product", new { Id = _pro.Id }));
                    }
                    return(RedirectToAction("List", "Product"));
                }
            }

            model.VatList      = Enums.VatList();
            model.BrandList    = GetBrandList();
            model.CategoryList = GetCategoryDropList();
            return(View(model));
        }
Esempio n. 7
0
        /// <summary>
        /// Return members by requested ids can be override for load extra data for resulting members
        /// </summary>
        /// <param name="memberIds"></param>
        /// <param name="responseGroup"></param>
        /// <param name="memberTypes"></param>
        /// <returns></returns>
        public virtual async Task <Member[]> GetByIdsAsync(string[] memberIds, string responseGroup = null, string[] memberTypes = null)
        {
            var cacheKey = CacheKey.With(GetType(), "GetByIdsAsync", string.Join("-", memberIds), responseGroup, memberTypes == null ? null : string.Join("-", memberTypes));

            return(await PlatformMemoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) =>
            {
                var retVal = new List <Member>();
                using (var repository = RepositoryFactory())
                {
                    repository.DisableChangesTracking();
                    //There is loading for all corresponding members conceptual model entities types
                    //query performance when TPT inheritance used it is too slow, for improve performance we are passing concrete member types in to the repository
                    var memberTypeInfos = AbstractTypeFactory <Member> .AllTypeInfos.Where(t => t.MappedType != null);
                    if (memberTypes != null)
                    {
                        memberTypeInfos = memberTypeInfos.Where(x => memberTypes.Any(mt => x.IsAssignableTo(mt)));
                    }
                    memberTypes = memberTypeInfos.Select(t => t.MappedType.AssemblyQualifiedName).Distinct().ToArray();

                    var dataMembers = await repository.GetMembersByIdsAsync(memberIds, responseGroup, memberTypes);
                    foreach (var dataMember in dataMembers)
                    {
                        var member = AbstractTypeFactory <Member> .TryCreateInstance(dataMember.MemberType);
                        if (member != null)
                        {
                            dataMember.ToModel(member);
                            retVal.Add(member);
                            cacheEntry.AddExpirationToken(CustomerCacheRegion.CreateChangeToken(member));
                        }
                    }
                }

                var taskDynamicProperty = DynamicPropertyService.LoadDynamicPropertyValuesAsync(retVal.ToArray <IHasDynamicProperties>());
                var taskSeo = SeoService.LoadSeoForObjectsAsync(retVal.OfType <ISeoSupport>().ToArray());
                await Task.WhenAll(taskDynamicProperty, taskSeo);

                return retVal.ToArray();
            }));
        }
Esempio n. 8
0
 public ContentController(PagesService pagesService, CategoriesService categoriesService, SeoService seoService)
 {
     _pagesService      = pagesService;
     _categoriesService = categoriesService;
     _seoService        = seoService;
 }
 public SyndicationController(SyndicationService _syndicationService, SeoService seoService)
 {
     this._syndicationService = _syndicationService;
     this.seoService = seoService;
 }
Esempio n. 10
0
 public SyndicationController(SyndicationService _syndicationService, SeoService seoService)
 {
     this._syndicationService = _syndicationService;
     this.seoService          = seoService;
 }