示例#1
0
        public HttpResponseMessage update(Newsletter post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(post.language_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }

            // Make sure that the data is valid
            post.title     = AnnytabDataValidation.TruncateString(post.title, 100);
            post.sent_date = AnnytabDataValidation.TruncateDateTime(post.sent_date);

            // Get the saved post
            Newsletter savedPost = Newsletter.GetOneById(post.id);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Update the post
            Newsletter.Update(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update method
示例#2
0
        public HttpResponseMessage add(GiftCard post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(post.language_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }
            else if (Currency.MasterPostExists(post.currency_code) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The currency does not exist"));
            }

            // Make sure that the data is valid
            post.id       = AnnytabDataValidation.TruncateString(post.id, 50);
            post.amount   = AnnytabDataValidation.TruncateDecimal(post.amount, 0, 999999999999M);
            post.end_date = AnnytabDataValidation.TruncateDateTime(post.end_date);

            // Check if the gift card exists
            if (GiftCard.MasterPostExists(post.id) == true)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The id already exists"));
            }

            // Add the post
            GiftCard.Add(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
示例#3
0
        public HttpResponseMessage update_theme(CustomTheme post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }

            // Make sure that the data is valid
            post.name = AnnytabDataValidation.TruncateString(post.name, 100);

            // Get the saved post
            CustomTheme savedPost = CustomTheme.GetOneById(post.id);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Update the post
            CustomTheme.Update(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update_theme method
示例#4
0
        public HttpResponseMessage add(StaticText post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }

            // Make sure that the data is valid
            post.id    = AnnytabDataValidation.TruncateString(post.id, 100);
            post.value = AnnytabDataValidation.TruncateString(post.value, 200);

            // Check if the id exists
            if (StaticText.MasterPostExists(post.id) == true)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The id already exists"));
            }

            // Make sure that the id contains valid characters
            if (AnnytabDataValidation.CheckPageNameCharacters(post.id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The id contains characters that not are allowed"));
            }

            // Add the post
            StaticText.Add(post, languageId);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
示例#5
0
        public HttpResponseMessage add(AdditionalService post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }
            else if (Unit.MasterPostExists(post.unit_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The unit does not exist"));
            }
            else if (ValueAddedTax.MasterPostExists(post.value_added_tax_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The value added tax does not exist"));
            }

            // Make sure that the data is valid
            post.product_code = AnnytabDataValidation.TruncateString(post.product_code, 50);
            post.name         = AnnytabDataValidation.TruncateString(post.name, 100);
            post.fee          = AnnytabDataValidation.TruncateDecimal(post.fee, 0, 9999999999.99M);
            post.account_code = AnnytabDataValidation.TruncateString(post.account_code, 10);

            // Add the post
            Int64 insertId = AdditionalService.AddMasterPost(post);

            post.id = Convert.ToInt32(insertId);
            AdditionalService.AddLanguagePost(post, languageId);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
        public HttpResponseMessage add(Company post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }

            // Make sure that the data is valid
            post.name = AnnytabDataValidation.TruncateString(post.name, 100);
            post.registered_office   = AnnytabDataValidation.TruncateString(post.registered_office, 100);
            post.org_number          = AnnytabDataValidation.TruncateString(post.org_number, 100);
            post.vat_number          = AnnytabDataValidation.TruncateString(post.vat_number, 100);
            post.phone_number        = AnnytabDataValidation.TruncateString(post.phone_number, 100);
            post.mobile_phone_number = AnnytabDataValidation.TruncateString(post.mobile_phone_number, 100);
            post.email          = AnnytabDataValidation.TruncateString(post.email, 100);
            post.post_address_1 = AnnytabDataValidation.TruncateString(post.post_address_1, 100);
            post.post_address_2 = AnnytabDataValidation.TruncateString(post.post_address_2, 100);
            post.post_code      = AnnytabDataValidation.TruncateString(post.post_code, 100);
            post.post_city      = AnnytabDataValidation.TruncateString(post.post_city, 100);
            post.post_country   = AnnytabDataValidation.TruncateString(post.post_country, 100);

            // Add the post
            Company.Add(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
示例#7
0
        public HttpResponseMessage update(ValueAddedTax post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }

            // Make sure that the data is valid
            post.value = AnnytabDataValidation.TruncateDecimal(post.value, 0, 9.99999M);

            // Get the saved post
            ValueAddedTax savedPost = ValueAddedTax.GetOneById(post.id);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Update the post
            ValueAddedTax.Update(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update method
        public HttpResponseMessage update(Currency post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }

            // Make sure that the data is valid
            post.currency_code   = AnnytabDataValidation.TruncateString(post.currency_code, 3);
            post.conversion_rate = AnnytabDataValidation.TruncateDecimal(post.conversion_rate, 0, 9999.999999M);

            // Get the saved post
            Currency savedPost = Currency.GetOneById(post.currency_code);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Update the post
            Currency.Update(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update method
        public HttpResponseMessage update(OrderGiftCard post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Order.MasterPostExists(post.order_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The order does not exist"));
            }
            else if (GiftCard.MasterPostExists(post.gift_card_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The gift card does not exist"));
            }

            // Make sure that the data is valid
            post.gift_card_id = AnnytabDataValidation.TruncateString(post.gift_card_id, 50);
            post.amount       = AnnytabDataValidation.TruncateDecimal(post.amount, 0, 999999999999M);

            // Get the saved post
            OrderGiftCard savedPost = OrderGiftCard.GetOneById(post.order_id, post.gift_card_id);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Update the post
            OrderGiftCard.Update(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update method
示例#10
0
        public HttpResponseMessage update(InspirationImageMap post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (post.language_id != 0 && Language.MasterPostExists(post.language_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }
            else if (post.category_id != 0 && Category.MasterPostExists(post.category_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The category does not exist"));
            }

            // Make sure that the data is valid
            post.name       = AnnytabDataValidation.TruncateString(post.name, 50);
            post.image_name = AnnytabDataValidation.TruncateString(post.image_name, 100);

            // Get the saved post
            InspirationImageMap savedPost = InspirationImageMap.GetOneById(post.id);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Update the post
            InspirationImageMap.Update(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update method
示例#11
0
        public HttpResponseMessage update(ProductBundle post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }

            // Make sure that the data is valid
            post.quantity = AnnytabDataValidation.TruncateDecimal(post.quantity, 0, 999999.99M);

            // Get the saved post
            ProductBundle savedPost = ProductBundle.GetOneById(post.bundle_product_id, post.product_id);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Update the post
            ProductBundle.Update(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update method
示例#12
0
        public HttpResponseMessage add(ProductBundle post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Product.MasterPostExists(post.bundle_product_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The bundle product does not exist"));
            }
            else if (Product.MasterPostExists(post.product_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The product does not exist"));
            }
            else if (ProductBundle.GetOneById(post.bundle_product_id, post.product_id) != null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The product bundle already exists"));
            }

            // Make sure that the data is valid
            post.quantity = AnnytabDataValidation.TruncateDecimal(post.quantity, 0, 999999.99M);

            // Add the post
            ProductBundle.Add(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
        public HttpResponseMessage add(ProductReview post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Product.MasterPostExists(post.product_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The product does not exist"));
            }
            else if (Customer.MasterPostExists(post.customer_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The customer does not exist"));
            }
            else if (Language.MasterPostExists(post.language_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }

            // Make sure that the data is valid
            post.review_date = AnnytabDataValidation.TruncateDateTime(post.review_date);
            post.rating      = AnnytabDataValidation.TruncateDecimal(post.rating, 0, 999999.99M);

            // Add the post
            ProductReview.Add(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
示例#14
0
        public HttpResponseMessage add(Language post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(languageId) == false && languageId != 0)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The translation language does not exist"));
            }

            // Make sure that the data is valid
            post.name          = AnnytabDataValidation.TruncateString(post.name, 50);
            post.language_code = AnnytabDataValidation.TruncateString(post.language_code, 2);
            post.country_code  = AnnytabDataValidation.TruncateString(post.country_code, 2);

            // Add the master post
            Int64 insertId = Language.AddMasterPost(post);

            post.id = Convert.ToInt32(insertId);

            // Set the translation language to the same as the language
            if (languageId == 0)
            {
                languageId = post.id;
            }

            // Add the language post
            Language.AddLanguagePost(post, languageId);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
示例#15
0
        public HttpResponseMessage add(InspirationImageMap post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (post.language_id != 0 && Language.MasterPostExists(post.language_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }
            else if (post.category_id != 0 && Category.MasterPostExists(post.category_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The category does not exist"));
            }

            // Make sure that the data is valid
            post.name       = AnnytabDataValidation.TruncateString(post.name, 50);
            post.image_name = AnnytabDataValidation.TruncateString(post.image_name, 100);

            // Add the post
            InspirationImageMap.Add(post);;

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
        public HttpResponseMessage update(OptionType post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }

            // Make sure that the data is valid
            post.title       = AnnytabDataValidation.TruncateString(post.title, 100);
            post.google_name = AnnytabDataValidation.TruncateString(post.google_name, 50);

            // Get the saved post
            OptionType savedPost = OptionType.GetOneById(post.id, languageId);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Update the post
            OptionType.UpdateMasterPost(post);
            OptionType.UpdateLanguagePost(post, languageId);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update method
        public HttpResponseMessage add(OptionType post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }

            // Make sure that the data is valid
            post.title       = AnnytabDataValidation.TruncateString(post.title, 100);
            post.google_name = AnnytabDataValidation.TruncateString(post.google_name, 50);

            // Add the post
            Int64 insertId = OptionType.AddMasterPost(post);

            post.id = Convert.ToInt32(insertId);
            OptionType.AddLanguagePost(post, languageId);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
        public HttpResponseMessage add(ProductOption post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (ProductOptionType.MasterPostExists(post.product_option_type_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The product option type does not exist"));
            }
            else if (Option.MasterPostExists(post.option_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The option does not exist"));
            }

            // Make sure that the data is valid
            post.mpn_suffix       = AnnytabDataValidation.TruncateString(post.mpn_suffix, 10);
            post.price_addition   = AnnytabDataValidation.TruncateDecimal(post.price_addition, 0, 9999999999.99M);
            post.freight_addition = AnnytabDataValidation.TruncateDecimal(post.freight_addition, 0, 9999999999.99M);

            // Add the post
            ProductOption.Add(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
示例#19
0
        public HttpResponseMessage translate(Product post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }
            else if (Product.MasterPostExists(post.id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The product does not exist"));
            }
            else if (ValueAddedTax.MasterPostExists(post.value_added_tax_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The value added tax does not exist"));
            }

            // Make sure that the data is valid
            post.title                 = AnnytabDataValidation.TruncateString(post.title, 200);
            post.meta_description      = AnnytabDataValidation.TruncateString(post.meta_description, 200);
            post.meta_keywords         = AnnytabDataValidation.TruncateString(post.meta_keywords, 200);
            post.page_name             = AnnytabDataValidation.TruncateString(post.page_name, 100);
            post.delivery_time         = AnnytabDataValidation.TruncateString(post.delivery_time, 50);
            post.affiliate_link        = AnnytabDataValidation.TruncateString(post.affiliate_link, 100);
            post.rating                = AnnytabDataValidation.TruncateDecimal(post.rating, 0, 999999.99M);
            post.toll_freight_addition = AnnytabDataValidation.TruncateDecimal(post.toll_freight_addition, 0, 9999999999.99M);
            post.account_code          = AnnytabDataValidation.TruncateString(post.account_code, 10);
            post.google_category       = AnnytabDataValidation.TruncateString(post.google_category, 300);
            post.availability_status   = AnnytabDataValidation.TruncateString(post.availability_status, 50);
            post.availability_date     = AnnytabDataValidation.TruncateDateTime(post.availability_date);

            // Get a product on page name
            Product productOnPageName = Product.GetOneByPageName(post.page_name, languageId);

            // Check if the page name exists
            if (productOnPageName != null && post.id != productOnPageName.id)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The page name is not unique for the language"));
            }

            // Get the post
            Product savedPost = Product.GetOneById(post.id, languageId);

            // Check if we should add or update the post
            if (savedPost == null)
            {
                Product.AddLanguagePost(post, languageId);
            }
            else
            {
                Product.UpdateLanguagePost(post, languageId);
            }

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The translate was successful"));
        } // End of the translate method
示例#20
0
        public HttpResponseMessage add(Customer post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(post.language_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }
            else if (Country.MasterPostExists(post.invoice_country) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The invoice country does not exist"));
            }
            else if (Country.MasterPostExists(post.delivery_country) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The delivery country does not exist"));
            }

            // Make sure that the data is valid
            post.email               = AnnytabDataValidation.TruncateString(post.email, 100);
            post.customer_password   = PasswordHash.CreateHash(post.customer_password);
            post.org_number          = AnnytabDataValidation.TruncateString(post.org_number, 20);
            post.vat_number          = AnnytabDataValidation.TruncateString(post.vat_number, 20);
            post.contact_name        = AnnytabDataValidation.TruncateString(post.contact_name, 100);
            post.phone_number        = AnnytabDataValidation.TruncateString(post.phone_number, 100);
            post.mobile_phone_number = AnnytabDataValidation.TruncateString(post.mobile_phone_number, 100);
            post.invoice_name        = AnnytabDataValidation.TruncateString(post.invoice_name, 100);
            post.invoice_address_1   = AnnytabDataValidation.TruncateString(post.invoice_address_1, 100);
            post.invoice_address_2   = AnnytabDataValidation.TruncateString(post.invoice_address_2, 100);
            post.invoice_post_code   = AnnytabDataValidation.TruncateString(post.invoice_post_code, 100);
            post.invoice_city        = AnnytabDataValidation.TruncateString(post.invoice_city, 100);
            post.delivery_name       = AnnytabDataValidation.TruncateString(post.delivery_name, 100);
            post.delivery_address_1  = AnnytabDataValidation.TruncateString(post.delivery_address_1, 100);
            post.delivery_address_2  = AnnytabDataValidation.TruncateString(post.delivery_address_2, 100);
            post.delivery_post_code  = AnnytabDataValidation.TruncateString(post.delivery_post_code, 100);
            post.delivery_city       = AnnytabDataValidation.TruncateString(post.delivery_city, 100);
            post.facebook_user_id    = AnnytabDataValidation.TruncateString(post.facebook_user_id, 50);
            post.google_user_id      = AnnytabDataValidation.TruncateString(post.google_user_id, 50);

            // Get a customer on the email address
            Customer customerOnEmail = Customer.GetOneByEmail(post.email);

            // Check if the email exists
            if (customerOnEmail != null && post.id != customerOnEmail.id)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The email is not unique"));
            }

            // Add the post
            Int32 insertId = (Int32)Customer.Add(post);

            // Update the password
            Customer.UpdatePassword(insertId, post.customer_password);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
示例#21
0
        public HttpResponseMessage add(Domain post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Country.MasterPostExists(post.country_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The country does not exist"));
            }
            else if (Language.MasterPostExists(post.front_end_language) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The front end language does not exist"));
            }
            else if (Language.MasterPostExists(post.back_end_language) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The back end language does not exist"));
            }
            else if (Currency.MasterPostExists(post.currency) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The currency does not exist"));
            }
            else if (Company.MasterPostExists(post.company_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The company does not exist"));
            }
            else if (post.custom_theme_id != 0 && CustomTheme.MasterPostExists(post.custom_theme_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The theme does not exist"));
            }
            else if (Domain.GetOneByDomainName(post.domain_name) != null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The domain name is not unique"));
            }

            // Make sure that the data is valid
            post.webshop_name          = AnnytabDataValidation.TruncateString(post.webshop_name, 100);
            post.domain_name           = AnnytabDataValidation.TruncateString(post.domain_name, 100);
            post.web_address           = AnnytabDataValidation.TruncateString(post.web_address, 100);
            post.analytics_tracking_id = AnnytabDataValidation.TruncateString(post.analytics_tracking_id, 50);
            post.facebook_app_id       = AnnytabDataValidation.TruncateString(post.facebook_app_id, 50);
            post.facebook_app_secret   = AnnytabDataValidation.TruncateString(post.facebook_app_secret, 50);
            post.google_app_id         = AnnytabDataValidation.TruncateString(post.google_app_id, 100);
            post.google_app_secret     = AnnytabDataValidation.TruncateString(post.google_app_secret, 50);

            // Add the post
            Domain.Add(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
示例#22
0
        public HttpResponseMessage update_gift_cards_amount(Int32 id = 0, decimal giftCardsAmount = 0)
        {
            // Make sure that the data is valid
            giftCardsAmount = AnnytabDataValidation.TruncateDecimal(giftCardsAmount, 0, 999999999999M);

            // Update the gift cards amount for the order
            Order.UpdateGiftCardsAmount(id, giftCardsAmount);

            // Create the response to return
            HttpResponseMessage response = Request.CreateResponse <string>(HttpStatusCode.OK, "Order has been updated");

            // Return the response
            return(response);
        } // End of the update_gift_cards_amount method
示例#23
0
        public HttpResponseMessage translate(StaticPage post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }
            else if (StaticPage.MasterPostExists(post.id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The static page does not exist"));
            }

            // Make sure that the data is valid
            post.link_name        = AnnytabDataValidation.TruncateString(post.link_name, 100);
            post.title            = AnnytabDataValidation.TruncateString(post.title, 200);
            post.meta_description = AnnytabDataValidation.TruncateString(post.meta_description, 200);
            post.meta_keywords    = AnnytabDataValidation.TruncateString(post.meta_keywords, 200);
            post.meta_robots      = AnnytabDataValidation.TruncateString(post.meta_robots, 20);
            post.page_name        = AnnytabDataValidation.TruncateString(post.page_name, 100);

            // Get a static page on page name
            StaticPage staticPageOnPageName = StaticPage.GetOneByPageName(post.page_name, languageId);

            // Check if the page name exists
            if (staticPageOnPageName != null && post.id != staticPageOnPageName.id)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The page name is not unique for the language"));
            }

            // Get the post
            StaticPage savedPost = StaticPage.GetOneById(post.id, languageId);

            // Check if we should add or update the post
            if (savedPost == null)
            {
                StaticPage.AddLanguagePost(post, languageId);
            }
            else
            {
                StaticPage.UpdateLanguagePost(post, languageId);
            }

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The translate was successful"));
        } // End of the translate method
示例#24
0
        public HttpResponseMessage add(ValueAddedTax post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }

            // Make sure that the data is valid
            post.value = AnnytabDataValidation.TruncateDecimal(post.value, 0, 9.99999M);

            // Add the post
            ValueAddedTax.Add(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
示例#25
0
        public HttpResponseMessage update(Category post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }

            // Make sure that the data is valid
            post.title            = AnnytabDataValidation.TruncateString(post.title, 100);
            post.meta_description = AnnytabDataValidation.TruncateString(post.meta_description, 200);
            post.meta_keywords    = AnnytabDataValidation.TruncateString(post.meta_keywords, 200);
            post.meta_robots      = AnnytabDataValidation.TruncateString(post.meta_robots, 20);
            post.page_name        = AnnytabDataValidation.TruncateString(post.page_name, 100);
            post.date_added       = AnnytabDataValidation.TruncateDateTime(post.date_added);

            // Get the saved post
            Category savedPost = Category.GetOneById(post.id, languageId);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Get a category on page name
            Category categoryOnPageName = Category.GetOneByPageName(post.page_name, languageId);

            // Check if the page name exists
            if (categoryOnPageName != null && post.id != categoryOnPageName.id)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The page name is not unique for the language"));
            }

            // Update the post
            Category.UpdateMasterPost(post);
            Category.UpdateLanguagePost(post, languageId);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update method
        public HttpResponseMessage update(PaymentOption post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }
            else if (Unit.MasterPostExists(post.unit_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The unit does not exist"));
            }
            else if (ValueAddedTax.MasterPostExists(post.value_added_tax_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The value added tax does not exist"));
            }

            // Make sure that the data is valid
            post.product_code      = AnnytabDataValidation.TruncateString(post.product_code, 50);
            post.name              = AnnytabDataValidation.TruncateString(post.name, 100);
            post.payment_term_code = AnnytabDataValidation.TruncateString(post.payment_term_code, 10);
            post.fee          = AnnytabDataValidation.TruncateDecimal(post.fee, 0, 9999999999.99M);
            post.account_code = AnnytabDataValidation.TruncateString(post.account_code, 10);

            // Get the saved post
            PaymentOption savedPost = PaymentOption.GetOneById(post.id, languageId);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Update the post
            PaymentOption.UpdateMasterPost(post);
            PaymentOption.UpdateLanguagePost(post, languageId);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update method
示例#27
0
        public HttpResponseMessage add_theme(CustomTheme post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }

            // Make sure that the data is valid
            post.name = AnnytabDataValidation.TruncateString(post.name, 100);

            // Add the post
            Int32 insertId = (Int32)CustomTheme.Add(post);

            CustomTheme.AddCustomThemeTemplates(insertId);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add_theme method
示例#28
0
        public HttpResponseMessage update(OrderRow post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Order.MasterPostExists(post.order_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The order does not exist"));
            }
            else if (Unit.MasterPostExists(post.unit_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The unit does not exist"));
            }

            // Make sure that the data is valid
            post.product_code      = AnnytabDataValidation.TruncateString(post.product_code, 50);
            post.manufacturer_code = AnnytabDataValidation.TruncateString(post.manufacturer_code, 50);
            post.gtin            = AnnytabDataValidation.TruncateString(post.gtin, 20);
            post.product_name    = AnnytabDataValidation.TruncateString(post.product_name, 100);
            post.vat_percent     = AnnytabDataValidation.TruncateDecimal(post.vat_percent, 0, 9.99999M);
            post.quantity        = AnnytabDataValidation.TruncateDecimal(post.quantity, 0, 999999.99M);
            post.unit_price      = AnnytabDataValidation.TruncateDecimal(post.unit_price, 0, 9999999999.99M);
            post.account_code    = AnnytabDataValidation.TruncateString(post.account_code, 10);
            post.supplier_erp_id = AnnytabDataValidation.TruncateString(post.supplier_erp_id, 20);

            // Get the saved post
            OrderRow savedPost = OrderRow.GetOneById(post.order_id, post.product_code);

            // Check if the post exists
            if (savedPost == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The record does not exist"));
            }

            // Update the post
            OrderRow.Update(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The update was successful"));
        } // End of the update method
示例#29
0
        public HttpResponseMessage translate(AdditionalService post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }
            else if (AdditionalService.MasterPostExists(post.id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The additional service does not exist"));
            }
            else if (ValueAddedTax.MasterPostExists(post.value_added_tax_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The value added tax does not exist"));
            }

            // Make sure that the data is valid
            post.product_code = AnnytabDataValidation.TruncateString(post.product_code, 50);
            post.name         = AnnytabDataValidation.TruncateString(post.name, 100);
            post.fee          = AnnytabDataValidation.TruncateDecimal(post.fee, 0, 9999999999.99M);
            post.account_code = AnnytabDataValidation.TruncateString(post.account_code, 10);

            // Get the saved post
            AdditionalService savedPost = AdditionalService.GetOneById(post.id, languageId);

            // Check if we should add or update the post
            if (savedPost == null)
            {
                AdditionalService.AddLanguagePost(post, languageId);
            }
            else
            {
                AdditionalService.UpdateLanguagePost(post, languageId);
            }

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The translation was successful"));
        } // End of the translate method
示例#30
0
        public HttpResponseMessage add(Newsletter post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Language.MasterPostExists(post.language_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The language does not exist"));
            }

            // Make sure that the data is valid
            post.title     = AnnytabDataValidation.TruncateString(post.title, 100);
            post.sent_date = AnnytabDataValidation.TruncateDateTime(post.sent_date);

            // Add the post
            Newsletter.Add(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method