Ejemplo n.º 1
0
        public static void Delete(int vendorID, int organizationID, string uid)
        {
            Vendor OriginalVendor = new Vendor(vendorID, organizationID);

            try
            {
                if (vendorID <= 0)
                {
                    throw new ArgumentException("Vendor ID is required to perform delete.", "VendorID");
                }
                if (organizationID <= 0)
                {
                    throw new ArgumentNullException("Organization ID is required to perform delete", "OrganizationID");
                }
                if (String.IsNullOrEmpty(uid))
                {
                    throw new ArgumentNullException("User ID is required to perform delete.", "uid");
                }

                using (PurchasingContext context = ContextHelper.GetDBContext())
                {
                    VendorData Data = context.VendorDatas.Where(x => x.vendor_id == vendorID && x.organization_id == organizationID).FirstOrDefault();
                    context.VendorDatas.DeleteOnSubmit(Data);

                    context.SubmitChanges();
                }

                OriginalVendor.SaveHistory(HistoryType.DELETE, null, uid);
            }
            catch (Exception ex)
            {
                throw new VendorException("An error has occurred while deleting vendor.", ex);
            }
        }
Ejemplo n.º 2
0
 public void Update(VendorData data)
 {
     // copy the applicable properties, if they are valid
     UpdateInternalState(data);
     VendorDAO.Update(internalState);
     // from generated code
 }
Ejemplo n.º 3
0
 private void Load(Guid guid)
 {
     using (PurchasingContext Context = ContextHelper.GetDBContext())
     {
         VendorData Data = Context.VendorDatas.FirstOrDefault(v => v.vendor_guid == guid);
     }
 }
Ejemplo n.º 4
0
        private void Load(VendorData data)
        {
            Initialize();
            if (data != null)
            {
                VendorID       = data.vendor_id;
                VendorName     = data.vendor_name;
                VendorGUID     = data.vendor_guid;
                OrganizationID = data.organization_id;
                mDateCreated   = data.date_created;
                mCreatedByUser = data.created_by;
                DateModified   = data.date_modified;
                ModifiedByUser = data.modified_by;
                if (!String.IsNullOrEmpty(data.address))
                {
                    Address = new Helpers.Address(data.address);
                }

                if (!String.IsNullOrEmpty(data.phone))
                {
                    Phone = new Helpers.PhoneNumber(data.phone);
                }

                WebAddress = data.web_address;
                Active     = data.active;
                Terms      = data.terms;
            }
        }
Ejemplo n.º 5
0
        private void EnsureMandatoryValuesAreProvided(VendorData vendor)
        {
            var vendorDataErrors = new StringBuilder();

            if (vendor == null)
            {
                vendorDataErrors.Append("\n- No vendor data present in the test data");
            }
            else
            {
                if (string.IsNullOrWhiteSpace(vendor.Vendor))
                {
                    vendorDataErrors.Append("\n- Vendor Name not set");
                }

                if (string.IsNullOrWhiteSpace(vendor.Country))
                {
                    vendorDataErrors.Append("\n- Vendor Country not set");
                }

                if (vendor.Categories == null || !vendor.Categories.Any())
                {
                    vendorDataErrors.Append("\n- Vendor Categories not set. Must have at least one category");
                }
            }

            if (!string.IsNullOrEmpty(vendorDataErrors.ToString()))
            {
                throw new ArgumentException($"The feature file {FeatureContext.FeatureInfo.Title} has the following data issues:\n {vendorDataErrors}");
            }
        }
Ejemplo n.º 6
0
        private void Load(int vendorId, int organizationId)
        {
            using (PurchasingContext Context = ContextHelper.GetDBContext())
            {
                VendorData Data = Context.VendorDatas.Where(v => v.organization_id == organizationId).Where(v => v.vendor_id == vendorId).FirstOrDefault();

                Load(Data);
            }
        }
Ejemplo n.º 7
0
        public void EditVendor(VendorData vendor)
        {
            EnsureMandatoryValuesAreProvided(vendor);

            ClearInputAndTypeValue(_txtVendorName, vendor.Vendor);
            SetWebformCheckBoxState(_chkTaxOtherCosts, vendor.TaxOtherCosts);
            ConfigureCheckboxes(vendor.Categories);

            ClickElement(_btnSave);
        }
Ejemplo n.º 8
0
        } // Map function closer

        public List <SqlParameter> MapParamsForUpsert(VendorData entity)
        {
            var sql_params = new List <SqlParameter>();

            sql_params.Add(new SqlParameter("@vendor_key", entity.VendorKey));
            sql_params.Add(new SqlParameter("@vendor_code", entity.VendorCode));
            sql_params.Add(new SqlParameter("@vendor_name", entity.VendorName));
            sql_params.Add(new SqlParameter("@vendor_desc", entity.VendorDesc));
            sql_params.Add(GetOutParam());
            return(sql_params);
        }
Ejemplo n.º 9
0
        public void CreateVendor(VendorData vendor)
        {
            EnsureMandatoryValuesAreProvided(vendor);

            ClearInputAndTypeValue(_txtVendorName, vendor.Vendor);
            SelectWebformDropdownValueByText(_ddlCountry, vendor.Country);
            SetWebformCheckBoxState(_chkTaxOtherCosts, vendor.TaxOtherCosts);
            ConfigureCheckboxes(vendor.Categories);

            ClickElement(_btnSave);
        }
Ejemplo n.º 10
0
 protected override void LazySet()
 {
     base.LazySet();
     if (PersistenceState == PersistenceState.NewAndChanged || PersistenceState == PersistenceState.LoadedAndChanged)
     {
         if ((object)InnerData == (object)OriginalData)
         {
             OriginalData = new VendorData(InnerData);
         }
     }
 }
Ejemplo n.º 11
0
        public Vendor(VendorData data)
        {
            // initialize the internal state
            SetInitialState();

            // copy the applicable properties, if they are valid
            UpdateInternalState(data);

            // insert new record
            IdType id = VendorDAO.Insert(internalState);

            internalState.VendorID = id;
        }
Ejemplo n.º 12
0
 public VendorData(VendorData data)
 {
     AccountNumber           = data.AccountNumber;
     Name                    = data.Name;
     CreditRating            = data.CreditRating;
     PreferredVendorStatus   = data.PreferredVendorStatus;
     ActiveFlag              = data.ActiveFlag;
     PurchasingWebServiceURL = data.PurchasingWebServiceURL;
     Employee                = data.Employee;
     ProductVendor           = data.ProductVendor;
     ModifiedDate            = data.ModifiedDate;
     Uid = data.Uid;
 }
Ejemplo n.º 13
0
 public Vendor Map(VendorData vendor_data)
 {
     return(new Vendor()
     {
         VendorKey = vendor_data.VendorKey,
         VendorCode = vendor_data.VendorCode,
         VendorName = vendor_data.VendorName,
         VendorDesc = vendor_data.VendorDesc,
         AddedUserID = vendor_data.AuditAddUserId,
         AddedDateTime = vendor_data.AuditAddDatetime,
         UpdateUserID = vendor_data.AuditUpdateUserId,
         UpdateDateTime = vendor_data.AuditUpdateDatetime,
     });
 }
Ejemplo n.º 14
0
        private bool IsVendorForeignIdExist(VendorData data)
        {
            var vendorNameWithCountryCode = $"{data.Name} ({GetCountryCode(data.Country)})";

            WaitForElementToBeVisible(By.XPath($"//span[text()='{vendorNameWithCountryCode}']"));
            var actualForeignIdValue = FindElementByXPath($"//span[text()='{vendorNameWithCountryCode}']/ancestor::tr//a[contains(@id, 'lnkEditForeignId')]").Text;
            var isForeignIdExist     = false;

            if (!string.IsNullOrEmpty(actualForeignIdValue))
            {
                isForeignIdExist = true;
            }

            return(isForeignIdExist);
        }
Ejemplo n.º 15
0
 private void ClearVendorDataMappingsIfExist(VendorData data)
 {
     foreach (var field in data.Fields)
     {
         if (field.Name.ToLower().Equals("foreignid"))
         {
             if (IsVendorForeignIdExist(data) && !IsExistingVendorForeignIdCorrect(data))
             {
                 var vendorNameWithCountryCode = $"{data.Name} ({GetCountryCode(data.Country)})";
                 var _btnRemove = FindElementByXPath($"//span[text()='{vendorNameWithCountryCode}']/ancestor::tr//a[contains(@id, 'lkbRemove')]");
                 ScrollAndClickElement(_btnRemove);
             }
         }
     }
 }
Ejemplo n.º 16
0
        public bool SelectVendorToMapData(VendorData data)
        {
            ClearVendorDataMappingsIfExist(data);

            var vendorNameWithCountryCode = $"{data.Name} ({GetCountryCode(data.Country)})";
            var isSelectedSuccessful      = false;

            if (IsElementPresent(By.XPath($"//span[text()='{vendorNameWithCountryCode}']/ancestor::tr//a[text() ='Add']")))
            {
                WaitForElementToBeVisible(By.XPath($"//span[text()='{vendorNameWithCountryCode}']/ancestor::tr//a[text() ='Add']"));
                ScrollAndClickElement(FindElementByXPath($"//span[text()='{vendorNameWithCountryCode}']/ancestor::tr//a[text() ='Add']"));
                SwitchToFrame(FRAME_MAPPING_POPUP);
                isSelectedSuccessful = true;
            }

            return(isSelectedSuccessful);
        }
Ejemplo n.º 17
0
        public int Exists(string name)
        {
            VendorData data = new VendorData();

            try
            {
                return(data.Exists(name));
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "Exists");
                throw(ex);
            }
            finally
            {
                data = null;
            }
        }
Ejemplo n.º 18
0
        private bool IsExistingVendorForeignIdCorrect(VendorData data)
        {
            var vendorNameWithCountryCode = $"{data.Name} ({GetCountryCode(data.Country)})";

            WaitForElementToBeVisible(By.XPath($"//span[text()='{vendorNameWithCountryCode}']"));
            var foreignIdValue = string.Empty;

            foreach (var field in data.Fields)
            {
                if (field.Name.ToLower().Equals("foreignid"))
                {
                    foreignIdValue = field.Value;
                }
            }

            var actualForeignIdValue = FindElementByXPath($"//span[text()='{vendorNameWithCountryCode}']/ancestor::tr//a[contains(@id, 'lnkEditForeignId')]").Text;

            return(actualForeignIdValue.Equals(foreignIdValue));
        }
Ejemplo n.º 19
0
        public int AddVendor(Vendor vendor)
        {
            VendorData data = new VendorData();
            int        id   = 0;

            try
            {
                id = data.AddVendor(vendor);
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "AddVendor");
                throw (ex);
            }
            finally
            {
                data = null;
            }
            return(id);
        }
Ejemplo n.º 20
0
        public DataSet GetAllVendorsDataSet()
        {
            VendorData data = new VendorData();
            DataSet    ds   = new DataSet();

            try
            {
                ds = data.GetAllVendorsDataSet();
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetAllVendorsDataSet");
                throw (ex);
            }
            finally
            {
                data = null;
            }
            return(ds);
        }
Ejemplo n.º 21
0
        public bool RemoveVendor(int vendorID)
        {
            VendorData data = new VendorData();
            bool       ret  = false;

            try
            {
                ret = data.DeleteVendor(vendorID);
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "RemoveVendor");
                throw (ex);
            }
            finally
            {
                data = null;
            }
            return(ret);
        }
Ejemplo n.º 22
0
        public bool UpdateVendor(Vendor vendor)
        {
            VendorData data = new VendorData();
            bool       ret  = false;

            try
            {
                ret = data.UpdateVendor(vendor);
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "UpdateVendor");
                throw (ex);
            }
            finally
            {
                data = null;
            }
            return(ret);
        }
Ejemplo n.º 23
0
        public VendorCollection GetVendorsCollection(string where, string orderBy)
        {
            VendorData       data = new VendorData();
            VendorCollection col  = new VendorCollection();

            try
            {
                col = data.GetAllVendorsDynamicCollection(where, orderBy);
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetVendorsCollection");
                throw (ex);
            }
            finally
            {
                data = null;
            }
            return(col);
        }
Ejemplo n.º 24
0
        public DataSet GetVendorsDataSet(string where, string orderBy)
        {
            VendorData data = new VendorData();
            DataSet    ds   = new DataSet();

            try
            {
                ds = data.GetAllVendorsDynamicDataSet(where, orderBy);
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetVendorsDataSet");
                throw (ex);
            }
            finally
            {
                data = null;
            }
            return(ds);
        }
Ejemplo n.º 25
0
        public VendorCollection GetAllVendorsCollection()
        {
            VendorData       data = new VendorData();
            VendorCollection col  = new VendorCollection();

            try
            {
                col = data.GetAllVendorsCollection();
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetAllVendorsCollection");
                throw (ex);
            }
            finally
            {
                data = null;
            }
            return(col);
        }
Ejemplo n.º 26
0
        public Vendor GetVendor(int venderID)
        {
            VendorData data = new VendorData();
            Vendor     v    = new Vendor();

            try
            {
                v = data.GetVendor(venderID);
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetVendors");
                throw (ex);
            }
            finally
            {
                data = null;
            }
            return(v);
        }
Ejemplo n.º 27
0
        private async void Render(string json)
        {
            VendorData request = JsonConvert.DeserializeObject <VendorData>(json);

            //help plz
            int vendorIndex = 0;

            for (int i = 0; i < request.response.data.Length; i++)
            {
                if (request.response.data[i].vendor.vendorHash == 863940356)
                {
                    vendorIndex = i;
                }
            }

            //help plz
            var materialIndexes = new int[2];

            foreach (var category in request.response.data[vendorIndex].categories)
            {
                if (category.displayCategoryIndex == 1)
                {
                    materialIndexes = category.itemIndexes;
                }
            }

            foreach (var item in request.response.data[vendorIndex].sales)
            {
                if (materialIndexes.Contains(item.vendorItemIndex))
                {
                    ItemsList.Add(new Models.Item
                    {
                        Name     = item.item.displayProperties.name.Replace("Purchase ", ""),
                        Icon     = $"https://www.bungie.net{ item.item.displayProperties.icon }",
                        Quantity = item.quantity.ToString(),
                        Cost     = $"{ item.costs[0].quantity.ToString() } {item.costs[0].displayProperties.name}"
                    });
                }
            }
        }
Ejemplo n.º 28
0
 public Vendor(VendorData v)
 {
     Load(v);
 }
Ejemplo n.º 29
0
 private void UpdateInternalState(VendorData data)
 {
     if (data.VendorID.IsValid)
     {
         internalState.VendorID = data.VendorID;
     }
     if (data.VendorName.IsValid)
     {
         internalState.VendorName = data.VendorName;
     }
     if (data.VendorTypeID.IsValid)
     {
         internalState.VendorTypeID = data.VendorTypeID;
     }
     if (data.PhoneNumber.IsValid)
     {
         internalState.PhoneNumber = data.PhoneNumber;
     }
     if (data.Description.IsValid)
     {
         internalState.Description = data.Description;
     }
     if (data.OrderLeadMins.IsValid)
     {
         internalState.OrderLeadMins = data.OrderLeadMins;
     }
     if (data.MinimumOrderAmt.IsValid)
     {
         internalState.MinimumOrderAmt = data.MinimumOrderAmt;
     }
     if (data.GratuityOrderAmt.IsValid)
     {
         internalState.GratuityOrderAmt = data.GratuityOrderAmt;
     }
     if (data.GratuityPct.IsValid)
     {
         internalState.GratuityPct = data.GratuityPct;
     }
     if (data.TaxRate.IsValid)
     {
         internalState.TaxRate = data.TaxRate;
     }
     if (data.AccountNumber.IsValid)
     {
         internalState.AccountNumber = data.AccountNumber;
     }
     if (data.OrderEventTypeID.IsValid)
     {
         internalState.OrderEventTypeID = data.OrderEventTypeID;
     }
     if (data.EffectiveDate.IsValid)
     {
         internalState.EffectiveDate = data.EffectiveDate;
     }
     if (data.ExpirationDate.IsValid)
     {
         internalState.ExpirationDate = data.ExpirationDate;
     }
     if (data.ContactUserID.IsValid)
     {
         internalState.ContactUserID = data.ContactUserID;
     }
     if (data.LogoFile.IsValid)
     {
         internalState.LogoFile = data.LogoFile;
     }
     if (data.StatusNormal.IsValid)
     {
         internalState.StatusNormal = data.StatusNormal;
     }
     if (data.StatusBusy.IsValid)
     {
         internalState.StatusBusy = data.StatusBusy;
     }
     if (data.StatusVeryBusy.IsValid)
     {
         internalState.StatusVeryBusy = data.StatusVeryBusy;
     }
     if (data.DiscountRate.IsValid)
     {
         internalState.DiscountRate = data.DiscountRate;
     }
     if (data.IsPercent.IsValid)
     {
         internalState.IsPercent = data.IsPercent;
     }
     if (data.DefaultTerms.IsValid)
     {
         internalState.DefaultTerms = data.DefaultTerms;
     }
     if (data.IsCreditTranFeeDeducted.IsValid)
     {
         internalState.IsCreditTranFeeDeducted = data.IsCreditTranFeeDeducted;
     }
     if (data.BasisID.IsValid)
     {
         internalState.BasisID = data.BasisID;
     }
     if (data.IsOverrideLowerLevel.IsValid)
     {
         internalState.IsOverrideLowerLevel = data.IsOverrideLowerLevel;
     }
     if (data.VendorDescription.IsValid)
     {
         internalState.VendorDescription = data.VendorDescription;
     }
     if (data.DeliveryFee.IsValid)
     {
         internalState.DeliveryFee = data.DeliveryFee;
     }
     if (data.DeliveryFeeIsPercent.IsValid)
     {
         internalState.DeliveryFeeIsPercent = data.DeliveryFeeIsPercent;
     }
     if (data.DeliveryFeeOnTax.IsValid)
     {
         internalState.DeliveryFeeOnTax = data.DeliveryFeeOnTax;
     }
     if (data.LocationCount.IsValid)
     {
         internalState.LocationCount = data.LocationCount;
     }
     if (data.DefaultOrderEventTypeID.IsValid)
     {
         internalState.DefaultOrderEventTypeID = data.DefaultOrderEventTypeID;
     }
 }
Ejemplo n.º 30
0
        public int Save(string uid)
        {
            Vendor      OriginalVendor = null;
            HistoryType ht;

            Dictionary <string, string> ValErrors = new Dictionary <string, string>();

            if (!Validated(ref ValErrors))
            {
                throw new VendorNotValidException("Was not able to validate vendor.", ValErrors);
            }


            using (PurchasingContext Context = ContextHelper.GetDBContext())
            {
                VendorData Data;

                if (VendorID > 0)
                {
                    OriginalVendor = new Vendor(VendorID, OrganizationID);
                    ht             = HistoryType.UPDATE;
                    Data           = Context.VendorDatas.Where(x => x.vendor_id == VendorID && x.organization_id == OrganizationID).FirstOrDefault();
                }
                else
                {
                    ht   = HistoryType.ADD;
                    Data = new VendorData();
                    Data.date_created    = DateTime.Now;
                    Data.created_by      = uid;
                    Data.vendor_guid     = Guid.NewGuid();
                    Data.organization_id = 1;
                }

                Data.vendor_name = VendorName;

                if (Address == null || String.IsNullOrEmpty(Address.StreetAddress))
                {
                    Data.address = null;
                }
                else
                {
                    Data.address = Address.ToArenaFormat();
                }

                if (Phone == null || String.IsNullOrEmpty(Phone.Number))
                {
                    Data.phone = null;
                }
                else
                {
                    Data.phone = Phone.ToArenaFormat();
                }

                if (String.IsNullOrEmpty(WebAddress))
                {
                    Data.web_address = null;
                }
                else
                {
                    Data.web_address = WebAddress;
                }

                if (String.IsNullOrEmpty(Terms))
                {
                    Data.terms = null;
                }
                else
                {
                    Data.terms = Terms;
                }

                Data.modified_by   = uid;
                Data.date_modified = DateTime.Now;
                Data.active        = Active;

                if (VendorID == 0)
                {
                    Context.VendorDatas.InsertOnSubmit(Data);
                }

                try
                {
                    Context.SubmitChanges();
                }
                catch (System.Data.Linq.ChangeConflictException ex)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (System.Data.Linq.ObjectChangeConflict c in Context.ChangeConflicts)
                    {
                        sb.AppendFormat("Table {0} ID: {1}", Context.Mapping.GetTable(c.Object.GetType()), ((VendorData)c.Object).vendor_id);
                    }
                    throw new Exception(sb.ToString(), ex);
                }


                Load(Data);
            }
            SaveHistory(ht, OriginalVendor, uid);
            return(VendorID);
        }