예제 #1
0
        public ActionResult SaveOrEdit(EmailList emaillist)
        {
            if (ModelState.IsValid)
            {
                if (emaillist.Id == 0)
                {
                    EmailListRepository.Add(emaillist);
                }
                else
                {
                    EmailListRepository.Edit(emaillist);
                }
                EmailListRepository.Save();

                if (IsSuperAdmin)
                {
                    return(RedirectToAction("Index", new { storeId = emaillist.StoreId }));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(emaillist));
        }
예제 #2
0
        private void CopyStoreData(int copyStoreId, int newStoreId)
        {
            StoreDbContext.Configuration.ProxyCreationEnabled = false;


            try
            {
                var items = NavigationRepository.GetNavigationsByStoreId(copyStoreId, "");
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id      = 0;
                    s.StoreId = newStoreId;
                    NavigationRepository.Add(s);
                }
                NavigationRepository.Save();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CopyStore", newStoreId);
            }
            try
            {
                var items = LocationRepository.GetLocationsByStoreId(copyStoreId, "");
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id      = 0;
                    s.StoreId = newStoreId;
                    LocationRepository.Add(s);
                }
                LocationRepository.Save();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CopyStore", newStoreId);
            }
            try
            {
                var items = EmailListRepository.GetStoreEmailList(copyStoreId, "");
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id      = 0;
                    s.StoreId = newStoreId;
                    EmailListRepository.Add(s);
                }
                EmailListRepository.Save();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CopyStore", newStoreId);
            }
            try
            {
                var items = BrandRepository.GetBrandsByStoreId(copyStoreId, "");
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id      = 0;
                    s.StoreId = newStoreId;
                    BrandRepository.Add(s);
                }
                BrandRepository.Save();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CopyStore", newStoreId);
            }
            try
            {
                var items = ContactRepository.GetContactsByStoreId(copyStoreId, "");
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id      = 0;
                    s.StoreId = newStoreId;
                    ContactRepository.Add(s);
                }
                ContactRepository.Save();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CopyStore", newStoreId);
            }
            int productCategoryId = 0;

            try
            {
                var items = ProductCategoryRepository.GetProductCategoriesByStoreId(copyStoreId);
                foreach (var productCategory in items)
                {
                    var s = GeneralHelper.DataContractSerialization(productCategory);
                    s.Id      = 0;
                    s.StoreId = newStoreId;
                    ProductCategoryRepository.Add(s);
                    ProductCategoryRepository.Save();

                    productCategoryId = s.Id;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "ProductCategoryRepository:CopyStore");
            }

            int blogCategoryId = 0;
            int newsCategoryId = 0;

            try
            {
                var items = CategoryRepository.GetCategoriesByStoreId(copyStoreId, StoreConstants.BlogsType);
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id      = 0;
                    s.StoreId = newStoreId;
                    CategoryRepository.Add(s);
                    CategoryRepository.Save();

                    blogCategoryId = s.Id;
                }

                items = CategoryRepository.GetCategoriesByStoreId(copyStoreId, StoreConstants.NewsType);
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id      = 0;
                    s.StoreId = newStoreId;
                    CategoryRepository.Add(s);
                    CategoryRepository.Save();

                    newsCategoryId = s.Id;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CopyStore", newStoreId);
            }


            try
            {
                var items = ProductRepository.GetProductsByStoreId(copyStoreId, "");
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id = 0;
                    s.ProductCategoryId = productCategoryId;
                    s.StoreId           = newStoreId;
                    ProductRepository.Add(s);
                    ProductRepository.Save();
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CopyStore", newStoreId);
            }

            try
            {
                var items = ContentRepository.GetContentsByStoreId(copyStoreId, "", StoreConstants.BlogsType);
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id         = 0;
                    s.StoreId    = newStoreId;
                    s.CategoryId = blogCategoryId;
                    ContentRepository.Add(s);
                    ContentRepository.Save();
                }

                items = ContentRepository.GetContentsByStoreId(copyStoreId, "", StoreConstants.NewsType);
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id         = 0;
                    s.StoreId    = newStoreId;
                    s.CategoryId = newsCategoryId;
                    ContentRepository.Add(s);
                    ContentRepository.Save();
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CopyStore", newStoreId);
            }

            try
            {
                var items = LabelRepository.GetLabelsByStoreId(copyStoreId, "");
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id      = 0;
                    s.StoreId = newStoreId;
                    LabelRepository.Add(s);
                    LabelRepository.Save();
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CopyStore", newStoreId);
            }

            try
            {
                var items = ActivityRepository.GetActivitiesByStoreId(copyStoreId, "");
                foreach (var item in items)
                {
                    var s = GeneralHelper.DataContractSerialization(item);
                    s.Id      = 0;
                    s.StoreId = newStoreId;
                    ActivityRepository.Add(s);
                    ActivityRepository.Save();
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CopyStore", newStoreId);
            }
        }