Exemplo n.º 1
0
        public bool AddDealer(lwg_Dealer _newDealer)
        {
            bool success = true;

            try
            {
                _newDealer.AddressSearch = string.Format("{0}{1}{2}{3}{4}", _newDealer.AddressLine1.Trim(), string.IsNullOrEmpty(_newDealer.AddressLine2.Trim()) ? string.Empty : " " + _newDealer.AddressLine2.Trim()
                                                         , string.IsNullOrEmpty(_newDealer.City.Trim())?string.Empty:" " + _newDealer.City.Trim(), string.IsNullOrEmpty(_newDealer.State.Trim())?string.Empty:" " + _newDealer.State.Trim(), string.IsNullOrEmpty(_newDealer.Zip.Trim()) ? string.Empty : " " + _newDealer.Zip.Trim());
                dbContext.lwg_Dealer.Add(_newDealer);
                dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                LWGLog.WriteLog("Add Dealer", ex.Message);
                success = false;
            }
            return(success);
        }
Exemplo n.º 2
0
 public bool DeleteConvertion(int convertionID)
 {
     try
     {
         lwg_ShippingConvertionConfig config = dbContext.lwg_ShippingConvertionConfig.Where(c => c.ID == convertionID).FirstOrDefault();
         if (config != null)
         {
             dbContext.lwg_ShippingConvertionConfig.Remove(config);
             dbContext.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         LWGLog.WriteLog("Delete Shipping Convertion", ex.ToString());
         return(false);
     }
 }
Exemplo n.º 3
0
        public bool UpdateConvertion(int convertionID, int priceFrom, int priceTo, int chargeWeight, ShippingConvertionType type)
        {
            try
            {
                lwg_ShippingConvertionConfig config = dbContext.lwg_ShippingConvertionConfig.Where(c => c.ID == convertionID).FirstOrDefault();
                if (config != null)
                {
                    config.PriceFrom    = priceFrom;
                    config.PriceTo      = priceTo;
                    config.ChargeWeight = chargeWeight;
                    config.Type         = type.ToString();

                    dbContext.SaveChanges();
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                LWGLog.WriteLog("Update Shipping Convertion", ex.ToString());
                return(false);
            }
        }
Exemplo n.º 4
0
        public int AddConvertion(int priceFrom, int priceTo, int chargeWeight, ShippingConvertionType type)
        {
            try
            {
                lwg_ShippingConvertionConfig config = new lwg_ShippingConvertionConfig();
                config.PriceFrom    = priceFrom;
                config.PriceTo      = priceTo;
                config.Type         = type.ToString();
                config.ChargeWeight = chargeWeight;

                dbContext.lwg_ShippingConvertionConfig.Add(config);

                dbContext.SaveChanges();

                return(config.ID);;
            }
            catch (Exception ex)
            {
                LWGLog.WriteLog("Add Shipping Convertion Config", ex.ToString());

                return(0);
            }
        }
Exemplo n.º 5
0
        public bool UpdateDealer(lwg_Dealer _updateDealer, string newDealerID)
        {
            bool success = true;

            try
            {
                lwg_Dealer updateDealer = dbContext.lwg_Dealer.Where(d => d.DealerID == _updateDealer.DealerID).FirstOrDefault();
                if (updateDealer != null)
                {
                    if (string.IsNullOrEmpty(newDealerID))
                    {
                        updateDealer.AddressLine1  = _updateDealer.AddressLine1;
                        updateDealer.AddressLine2  = _updateDealer.AddressLine2;
                        updateDealer.City          = _updateDealer.City;
                        updateDealer.Contact       = _updateDealer.Contact;
                        updateDealer.Fax           = _updateDealer.Fax;
                        updateDealer.Name          = _updateDealer.Name;
                        updateDealer.NewIssue      = _updateDealer.NewIssue;
                        updateDealer.Phone         = _updateDealer.Phone;
                        updateDealer.WebAddress    = _updateDealer.WebAddress;
                        updateDealer.Zip           = _updateDealer.Zip;
                        updateDealer.State         = _updateDealer.State;
                        updateDealer.AddressSearch = string.Format("{0}{1}{2}{3}{4}", _updateDealer.AddressLine1.Trim(), string.IsNullOrEmpty(_updateDealer.AddressLine2.Trim()) ? string.Empty : " " + _updateDealer.AddressLine2.Trim()
                                                                   , string.IsNullOrEmpty(_updateDealer.City.Trim()) ? string.Empty : " " + _updateDealer.City.Trim(), string.IsNullOrEmpty(_updateDealer.State.Trim()) ? string.Empty : " " + _updateDealer.State.Trim(), string.IsNullOrEmpty(_updateDealer.Zip.Trim()) ? string.Empty : " " + _updateDealer.Zip.Trim());

                        dbContext.SaveChanges();
                    }
                    else
                    {
                        lwg_Dealer newDealer = new lwg_Dealer();
                        newDealer.DealerID      = newDealerID;
                        newDealer.AddressLine1  = _updateDealer.AddressLine1;
                        newDealer.AddressLine2  = _updateDealer.AddressLine2;
                        newDealer.City          = _updateDealer.City;
                        newDealer.Contact       = _updateDealer.Contact;
                        newDealer.Fax           = _updateDealer.Fax;
                        newDealer.Name          = _updateDealer.Name;
                        newDealer.NewIssue      = _updateDealer.NewIssue;
                        newDealer.Phone         = _updateDealer.Phone;
                        newDealer.WebAddress    = _updateDealer.WebAddress;
                        newDealer.Zip           = _updateDealer.Zip;
                        newDealer.State         = _updateDealer.State;
                        newDealer.AddressSearch = string.Format("{0}{1}{2}{3}{4}", _updateDealer.AddressLine1.Trim(), string.IsNullOrEmpty(_updateDealer.AddressLine2.Trim()) ? string.Empty : " " + _updateDealer.AddressLine2.Trim()
                                                                , string.IsNullOrEmpty(_updateDealer.City.Trim()) ? string.Empty : " " + _updateDealer.City.Trim(), string.IsNullOrEmpty(_updateDealer.State.Trim()) ? string.Empty : " " + _updateDealer.State.Trim(), string.IsNullOrEmpty(_updateDealer.Zip.Trim()) ? string.Empty : " " + _updateDealer.Zip.Trim());

                        dbContext.lwg_Dealer.Remove(updateDealer); // remove old dealer
                        dbContext.lwg_Dealer.Add(newDealer);       // add new dealer

                        dbContext.SaveChanges();
                    }
                }
                else
                {
                    LWGLog.WriteLog("Update Dealer", string.Format("DealerID = {0} does not exist!", _updateDealer.DealerID));
                    success = false;
                }
            }
            catch (Exception ex)
            {
                LWGLog.WriteLog("Update Dealer", ex.Message);
                success = false;
            }
            return(success);
        }