Esempio n. 1
0
        /// <summary>
        /// Updates an existing order
        /// </summary>
        public static bool UpdateOrder(int id, int statusID, DateTime shippedDate, string transactionID, string trackingID)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                transactionID = BizObject.ConvertNullToEmptyString(transactionID);
                trackingID    = BizObject.ConvertNullToEmptyString(trackingID);

                // retrieve the order's current status ID
                Order order = Order.GetOrderByID(id);

                // update the order
                OrderDetails record = new OrderDetails(id, DateTime.Now, "", statusID, "", "", 0.0m, 0.0m,
                                                       "", "", "", "", "", "", "", "", "", "", shippedDate, transactionID, trackingID);
                bool ret = SiteProvider.Store.UpdateOrder(record);

                // if the new status ID is confirmed, than decrease the UnitsInStock for the purchased products
                if (statusID == (int)StatusCode.Confirmed && order.StatusID == (int)StatusCode.WaitingForPayment)
                {
                    foreach (OrderItem item in order.Items)
                    {
                        Product.DecrementProductUnitsInStock(item.ProductID, item.Quantity);
                    }
                }

                BizObject.PurgeCacheItems("store_order");
                scope.Complete();
                return(ret);
            }
        }
        /// <summary>
        /// Updates an existing article
        /// </summary>
        public static bool UpdateArticle(int id, int categoryID, string title,
                                         string Abstract, string body, string country, string state, string city,
                                         DateTime releaseDate, DateTime expireDate, bool approved, bool listed,
                                         bool commentsEnabled, bool onlyForMembers)
        {
            title    = BizObject.ConvertNullToEmptyString(title);
            Abstract = BizObject.ConvertNullToEmptyString(Abstract);
            body     = BizObject.ConvertNullToEmptyString(body);
            country  = BizObject.ConvertNullToEmptyString(country);
            state    = BizObject.ConvertNullToEmptyString(state);
            city     = BizObject.ConvertNullToEmptyString(city);

            if (releaseDate == DateTime.MinValue)
            {
                releaseDate = DateTime.Now;
            }
            if (expireDate == DateTime.MinValue)
            {
                expireDate = DateTime.MaxValue;
            }

            ArticleDetails record = new ArticleDetails(id, DateTime.Now, "", categoryID,
                                                       "", title, Abstract, body, country, state, city, releaseDate, expireDate,
                                                       approved, listed, commentsEnabled, onlyForMembers, 0, 0, 0);
            bool ret = SiteProvider.Articles.UpdateArticle(record);

            BizObject.PurgeCacheItems("articles_article_" + id.ToString());
            BizObject.PurgeCacheItems("articles_articles");
            return(ret);
        }
        /// <summary>
        /// Updates an existing post
        /// </summary>
        public static bool UpdatePost(int id, string title, string body)
        {
            title = BizObject.ConvertNullToEmptyString(title);
            body  = BizObject.ConvertNullToEmptyString(body);

            PostDetails record = new PostDetails(id, DateTime.Now, "", "", 0, "", 0,
                                                 title, body, true, false, 0, 0, DateTime.Now, "");
            bool ret = SiteProvider.Forums.UpdatePost(record);

            BizObject.PurgeCacheItems("forums_unapprovedposts");
            BizObject.PurgeCacheItems("forums_threads");
            BizObject.PurgeCacheItems("forums_threadcount");
            BizObject.PurgeCacheItems("forums_thread_" + id.ToString());
            BizObject.PurgeCacheItems("forums_post_" + id.ToString());
            return(ret);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new product
        /// </summary>
        public static int InsertProduct(int departmentID, string title,
                                        string description, string sku, decimal unitPrice, int discountPercentage,
                                        int unitsInStock, string smallImageUrl, string fullImageUrl)
        {
            title         = BizObject.ConvertNullToEmptyString(title);
            description   = BizObject.ConvertNullToEmptyString(description);
            sku           = BizObject.ConvertNullToEmptyString(sku);
            smallImageUrl = BizObject.ConvertNullToEmptyString(smallImageUrl);
            fullImageUrl  = BizObject.ConvertNullToEmptyString(fullImageUrl);

            ProductDetails record = new ProductDetails(0, DateTime.Now, BizObject.CurrentUserName,
                                                       departmentID, "", title, description, sku, unitPrice, discountPercentage,
                                                       unitsInStock, smallImageUrl, fullImageUrl, 0, 0);
            int ret = SiteProvider.Store.InsertProduct(record);

            BizObject.PurgeCacheItems("store_product");
            return(ret);
        }
        /// <summary>
        /// Creates a new post
        /// </summary>
        public static int InsertPost(int forumID, int parentPostID,
                                     string title, string body, bool closed)
        {
            title = BizObject.ConvertNullToEmptyString(title);
            body  = BizObject.ConvertNullToEmptyString(body);

            // if the target forum is moderated, the current user must be an
            // admin, editor or moderator to insert the post in approved status
            bool  approved = true;
            Forum forum    = Forum.GetForumByID(forumID);

            if (forum.Moderated)
            {
                if (!BizObject.CurrentUser.IsInRole("Administrators") &&
                    !BizObject.CurrentUser.IsInRole("Editors") &&
                    !BizObject.CurrentUser.IsInRole("Moderators"))
                {
                    approved = false;
                }
            }

            PostDetails record = new PostDetails(0, DateTime.Now, BizObject.CurrentUserName, BizObject.CurrentUserIP,
                                                 forumID, "", parentPostID, title, body, approved, closed, 0, 0, DateTime.Now, BizObject.CurrentUserName);
            int ret = SiteProvider.Forums.InsertPost(record);

            if (approved)
            {
                BizObject.PurgeCacheItems("forums_threads");
                BizObject.PurgeCacheItems("forums_thread_" + parentPostID.ToString());
                BizObject.PurgeCacheItems("forums_threadcount");
            }
            else
            {
                BizObject.PurgeCacheItems("forums_unapprovedposts");
            }

            return(ret);
        }
        /// <summary>
        /// Creates a new article
        /// </summary>
        public static int InsertArticle(int categoryID, string title, string Abstract,
                                        string body, string country, string state, string city, DateTime releaseDate, DateTime expireDate,
                                        bool approved, bool listed, bool commentsEnabled, bool onlyForMembers)
        {
            // ensure that the "approved" option is false if the current user is not
            // an administrator or a editor (it may be a contributor for example)
            bool canApprove = (BizObject.CurrentUser.IsInRole("Administrators") || BizObject.CurrentUser.IsInRole("Editors"));

            if (!canApprove)
            {
                approved = false;
            }

            title    = BizObject.ConvertNullToEmptyString(title);
            Abstract = BizObject.ConvertNullToEmptyString(Abstract);
            body     = BizObject.ConvertNullToEmptyString(body);
            country  = BizObject.ConvertNullToEmptyString(country);
            state    = BizObject.ConvertNullToEmptyString(state);
            city     = BizObject.ConvertNullToEmptyString(city);

            if (releaseDate == DateTime.MinValue)
            {
                releaseDate = DateTime.Now;
            }
            if (expireDate == DateTime.MinValue)
            {
                expireDate = DateTime.MaxValue;
            }

            ArticleDetails record = new ArticleDetails(0, DateTime.Now, BizObject.CurrentUserName,
                                                       categoryID, "", title, Abstract, body, country, state, city, releaseDate, expireDate,
                                                       approved, listed, commentsEnabled, onlyForMembers, 0, 0, 0);
            int ret = SiteProvider.Articles.InsertArticle(record);

            BizObject.PurgeCacheItems("articles_article");
            return(ret);
        }