Exemple #1
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 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
        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
Exemple #4
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
        public HttpResponseMessage add(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 (Category.MasterPostExists(post.category_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The category 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, 20);
            post.manufacturer_code = AnnytabDataValidation.TruncateString(post.manufacturer_code, 20);
            post.gtin                    = AnnytabDataValidation.TruncateString(post.gtin, 20);
            post.unit_price              = AnnytabDataValidation.TruncateDecimal(post.unit_price, 0, 9999999999.99M);
            post.unit_freight            = AnnytabDataValidation.TruncateDecimal(post.unit_freight, 0, 9999999999.99M);
            post.mount_time_hours        = AnnytabDataValidation.TruncateDecimal(post.mount_time_hours, 0, 9999.99M);
            post.brand                   = AnnytabDataValidation.TruncateString(post.brand, 50);
            post.supplier_erp_id         = AnnytabDataValidation.TruncateString(post.supplier_erp_id, 20);
            post.meta_robots             = AnnytabDataValidation.TruncateString(post.meta_robots, 20);
            post.buys                    = AnnytabDataValidation.TruncateDecimal(post.buys, 0, 9999999999.99M);
            post.condition               = AnnytabDataValidation.TruncateString(post.condition, 20);
            post.variant_image_filename  = AnnytabDataValidation.TruncateString(post.variant_image_filename, 50);
            post.availability_status     = AnnytabDataValidation.TruncateString(post.availability_status, 50);
            post.availability_date       = AnnytabDataValidation.TruncateDateTime(post.availability_date);
            post.gender                  = AnnytabDataValidation.TruncateString(post.gender, 20);
            post.age_group               = AnnytabDataValidation.TruncateString(post.age_group, 20);
            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.unit_pricing_measure    = AnnytabDataValidation.TruncateDecimal(post.unit_pricing_measure, 0, 99999.99999M);
            post.size_type               = AnnytabDataValidation.TruncateString(post.size_type, 20);
            post.size_system             = AnnytabDataValidation.TruncateString(post.size_system, 10);
            post.energy_efficiency_class = AnnytabDataValidation.TruncateString(post.energy_efficiency_class, 10);
            post.date_added              = AnnytabDataValidation.TruncateDateTime(post.date_added);
            post.discount                = AnnytabDataValidation.TruncateDecimal(post.discount, 0, 9.999M);

            // 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"));
            }

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

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

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