コード例 #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
        public ActionResult DeleteConfirmed(int id)
        {
            EmailList emaillist = EmailListRepository.GetSingle(id);

            if (emaillist == null)
            {
                return(HttpNotFound());
            }
            try
            {
                EmailListRepository.Delete(emaillist);
                EmailListRepository.Save();

                if (IsSuperAdmin)
                {
                    return(RedirectToAction("Index", new { storeId = emaillist.StoreId }));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Unable to delete:" + emaillist, ex);
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            return(View(emaillist));
        }
コード例 #3
0
        private HttpResponseMessage ProcessExistingEmailListRecord(HttpRequestMessage request, EmailListDTO cqDto, int contactId, string key, int EmailListId, int userId)
        {
            var ur   = new EmailListRepository();
            var user = new EmailList();

            user = ur.GetById(contactId);


            var validationErrors = GetListValidationErrors(ur, user, cqDto, EmailListId, userId);

            if (validationErrors.Any())
            {
                return(ProcessValidationErrors(request, validationErrors, key));
            }

            ur.Save(user);


            cqDto.Key = key;
            return(request.CreateResponse(HttpStatusCode.Accepted, cqDto));
        }
コード例 #4
0
        private HttpResponseMessage ProcessNewEmailListRecord(HttpRequestMessage request, EmailListDTO uDto, string key, int EmailListId, int userId)
        {
            var ur   = new EmailListRepository();
            var user = new EmailList();


            var validationErrors = GetListValidationErrors(ur, user, uDto, EmailListId, userId);

            if (validationErrors.Any())
            {
                return(ProcessValidationErrors(request, validationErrors, key));
            }

            user             = ur.Save(user);
            uDto.Key         = key;
            uDto.EmailListId = user.EmailListId.ToString();
            var response = request.CreateResponse(HttpStatusCode.Created, uDto);

            response.Headers.Location = new Uri(Url.Link("Default", new
            {
                id = user.EmailListId
            }));
            return(response);
        }
コード例 #5
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);
            }
        }