示例#1
0
        public void UpdateStoreView(Store store)
        {
            for (int i = 0; i < this.Count; i++)
            {
                if (this[i].ID == store.ID)
                {
                    StoreView     view   = new StoreView(store);
                    Domain.Region region = GetRegion(view.RegionID);
                    if (region != null)
                    {
                        view.RegionName = region.Name;

                        Domain.Country country = GetCountry(region.CountryID);

                        if (country != null)
                        {
                            view.CountryID   = country.ID;
                            view.CountryName = country.Name;
                        }
                    }
                    this[i] = view;
                    return;
                }
            }
        }
示例#2
0
        public static void Do()
        {
            var countries = CountryRecord.Retrieve();

            using (var context = new ClimateContext())
            {
                context.Countries.RemoveRange(context.Countries.ToList());
                foreach (var country in countries.OrderByDescending(x => x.population))
                {
                    var dbCountry = new Domain.Country
                    {
                        Name       = country.name,
                        Population = country.population
                    };
                    context.Countries.Add(dbCountry);

                    var capital = new Domain.City
                    {
                        IsCapital = true,
                        Country   = dbCountry,
                        Name      = country.capital
                    };
                    context.Cities.Add(capital);
                    Console.WriteLine("{0} - done", country.name);
                }
                context.SaveChanges();
            }
        }
示例#3
0
        public void FireDeleteEntity(Domain.Country c)
        {
            if (ReadOnly)
            {
                return;
            }

            ShowCountryDetail();

            /*Domain.Country entity = c;
             * if (entity == null) entity = FocusedEntity;
             * if (entity != null)
             * {
             *  if (QuestionMessageYes(GetLocalized (UiConst.QUESTION_DELETE_COUNTRY)))
             *  {
             *      try
             *      {
             *          ClientEnvironment.CountryService.DeleteByID(entity.ID);
             *          _bindingEntities.Remove(entity);
             *      }
             *      catch (Exception ex)
             *      {
             *          ErrorMessage(ex.Message);
             *      }
             *
             *  }
             * }*/
        }
示例#4
0
 public CountryColourList(Domain.Country aCountry)
 {
     if (aCountry == null)
     {
         throw new NullReferenceException();
     }
     _country = aCountry;
 }
示例#5
0
 private void toolStripMenuItem_DeleteCountry_Click(object sender, EventArgs e)
 {
     Domain.Country entity = FocusedEntity;
     if (entity != null)
     {
         FireDeleteEntity(entity);
     }
 }
示例#6
0
 private Domain.Country GetEntityByRowHandle(int rowHandle)
 {
     Domain.Country entity = null;
     if (gridViewCountries.IsDataRow(rowHandle))
     {
         entity = (Domain.Country)gridViewCountries.GetRow(rowHandle);
     }
     return(entity);
 }
示例#7
0
        public void Handle(AddCountryCommand command)
        {
            var repository = this.contextFactory();


            var country = new Domain.Country(command.CountryId, command.Name,
                                             command.Code, command.PhoneCode, command.LanguageId, command.CurrencyId);


            repository.Save(country);
        }
示例#8
0
 private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
 {
     if (!EnabledContextMenu)
     {
         e.Cancel = true;
         return;
     }
     Domain.Country country = FocusedEntity;
     toolStripMenuItem_ImportCountry.Visible  = isUserGlobaAdministrator;
     toolStripMenuItem_EditCountry.Enabled    = country != null;
     toolStripMenuItem_CountryDetails.Enabled = country != null;
 }
示例#9
0
        public Domain.Country GetCountry(long id)
        {
            if (_countryDiction == null)
            {
                _countryDiction = new CountryDictionary();
                _countryDiction.Refresh();
            }

            Domain.Country c = null;
            _countryDiction.TryGetValue(id, out c);
            return(c);
        }
示例#10
0
 private void btnDelCountry_Click(object sender, EventArgs e)
 {
     if (lbCountries.SelectedItem != null)
     {
         if (QuestionMessage(GetLocalized("questionDeleteCountry"), GetLocalized("Confirm")) == DialogResult.Yes)
         {
             Domain.Country country = (Domain.Country)lbCountries.SelectedItem;
             _CountryBindList.Remove(country);
             Modified           = true;
             _CountriesModified = true;
         }
     }
 }
示例#11
0
 public void UpdateProperties()
 {
     _countryname = String.Empty;
     Domain.Country country = null;
     if (Entity != null && Entity.CountryID > 0)
     {
         country = ClientEnvironment.CountryService.FindById(Entity.CountryID);
         if (country != null)
         {
             _countryname = country.Name;
         }
     }
 }
示例#12
0
        private void gridControlCountries_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            GridHitInfo info = gridViewCountries.CalcHitInfo(e.X, e.Y);

            if (info.InRowCell && gridViewCountries.IsDataRow(info.RowHandle))
            {
                Domain.Country entity = GetEntityByRowHandle(info.RowHandle);
                if (entity != null)
                {
                    FireEditEntity(entity);
                }
            }
        }
示例#13
0
        private void NewCountry()
        {
            Domain.Country entity      = ClientEnvironment.CountryService.CreateEntity();
            FormCountry2   countryform = new FormCountry2();

            countryform.Country = entity;
            if (countryform.ShowDialog() == DialogResult.OK)
            {
                List <Domain.Country> l = new List <Baumax.Domain.Country>();
                l.Add(countryform.Country);

                _nodesList.AddCountries(l);
            }
        }
示例#14
0
 protected override void EntityChanged()
 {
     if (Entity != null)
     {
         GenerateEmployeeList();
         // ACPRO #121486 - show Peronal ID or Personal Number, depending of store's country
         Domain.Country storeCountry = ListStores.GetCountry(ListStores.GetById(EntityStore.ID).CountryID);
         gridColumn_PersonID.Visible = (storeCountry.PersShowMode == PersShowModeType.PersonalID ||
                                        storeCountry.PersShowMode == PersShowModeType.All);
         gridColumn_PersNumber.Visible = (storeCountry.PersShowMode == PersShowModeType.PersonalNumber ||
                                          storeCountry.PersShowMode == PersShowModeType.All);
     }
     base.EntityChanged();
 }
示例#15
0
        public override void Delete()
        {
            //XtraMessageBox.Show(this, "Delete", this.Name, MessageBoxButtons.OK);
            List <long> ids = new List <long>();

            foreach (int rowHandle in mainGridView.GetSelectedRows())
            {
                Domain.Country entity = (Domain.Country)mainGridView.GetRow(rowHandle);
                ids.Add(entity.ID);
            }
            //--ICountryService countrySvc = (ICountryService) AppCtx.GetObject("countryService");
            //countrySvc.Delete(ids.ToArray());
            _svc.DeleteListByID(ids);

            RefreshData();
        }
示例#16
0
        public static VmCountryDetails Build(Domain.Country entity)
        {
            return new VmCountryDetails
            {
                Name = entity.Name,
                Flag = entity.Flag,
                Alpha3Code = entity.Alpha3Code,
                Region = entity.Region,

                Population = entity.Population,
                CapitalCity = entity.Capital,
                Timezones = entity.Timezones,
                Currencies = entity.Currencies,
                Languages = entity.Languages,
                BorderingCountries = entity.Borders
            };
        }
示例#17
0
        public void FireEditEntity(Domain.Country c)
        {
            if (ReadOnly)
            {
                return;
            }
            if (FocusedEntity == null && c == null)
            {
                return;
            }

            using (FormCountryEdit edit = new FormCountryEdit(FocusedEntity))
            {
                edit.ShowDialog();
                return;
            }
        }
示例#18
0
        public async Task FetchCountryAsync_WithValidCountryId_ReturnsCountry()
        {
            using (DatabaseWrapper database = new DatabaseWrapper())
            {
                // Arrange
                Guid countryId = new Guid("184E1785-26B4-4AE4-80D3-AE319B103ACB"); // ID for UK - England

                OrganisationDetailsDataAccess dataAccess = new OrganisationDetailsDataAccess(database.WeeeContext);

                // Act
                Domain.Country result = await dataAccess.FetchCountryAsync(countryId);

                // Assert
                Assert.NotNull(result);
                Assert.Equal(countryId, result.Id);
                Assert.Equal(result.Name, "UK - England");
            }
        }
示例#19
0
        public void AddStoreView(StoreView view)
        {
            Domain.Region region = GetRegion(view.RegionID);
            if (region != null)
            {
                view.RegionName = region.Name;

                Domain.Country country = GetCountry(region.CountryID);

                if (country != null)
                {
                    view.CountryID   = country.ID;
                    view.CountryName = country.Name;
                }
            }

            Add(view);
        }
示例#20
0
        public async Task Returns_Country_Given_Found()
        {
            // Arrange
            const string code    = "Alpha3Code";
            var          country = new Domain.Country();

            GetMock <ICountryRepository>()
            .Setup(x => x.SearchByCodeAsync(code))
            .Returns(Task.FromResult(country));

            // Act
            var result = await ClassUnderTest.Get(code);

            // Assert
            result.Should().NotBeNull();

            result.Should().BeSameAs(country);
        }
示例#21
0
        public override void Edit()
        {
            //XtraMessageBox.Show(this, "Edit", this.Name, MessageBoxButtons.OK);
            Domain.Country l = (Domain.Country)mainGridView.GetRow(mainGridView.FocusedRowHandle);
            if (l == null)
            {
                return;
            }
            FormCountry f = new FormCountry();

            f.Text    = GetLocalized("Edit Country");
            f.Country = l;
            if (f.ShowDialog(OwnerForm) == DialogResult.OK)
            {
                _svc.SaveOrUpdate(f.Country);
            }

            RefreshData();
        }
示例#22
0
        private static void AssertSubmitted(WeeeContext context, Domain.Country country, Tuple <Guid, Guid> returnData, AatfAddress aatfAddress)
        {
            var testAddress = (context.WeeeReusedSite
                               .Where(t => t.WeeeReused.ReturnId == returnData.Item1 &&
                                      t.WeeeReused.Aatf.Id == returnData.Item2).FirstOrDefault()).Address;

            testAddress.Should().NotBeNull();
            testAddress.Name.Should().NotBeNullOrEmpty();
            testAddress.Name.Should().Be(aatfAddress.Name);
            testAddress.Address1.Should().NotBeNullOrEmpty();
            testAddress.Address1.Should().Be(aatfAddress.Address1);
            testAddress.Address2.Should().Be(aatfAddress.Address2);
            testAddress.TownOrCity.Should().NotBeNullOrEmpty();
            testAddress.TownOrCity.Should().Be(aatfAddress.TownOrCity);
            testAddress.CountyOrRegion.Should().Be(aatfAddress.CountyOrRegion);
            testAddress.Postcode.Should().Be(aatfAddress.Postcode);
            testAddress.CountryId.Should().NotBeEmpty();
            testAddress.CountryId.Should().Be(country.Id);
        }
示例#23
0
        public async Task <AddCountryPayload> AddCountryAsync(
            AddCountryInput input,
            [ScopedService] GeoDbContext context,
            [Service] ITopicEventSender eventSender,
            CancellationToken cancellationToken
            )
        {
            var country = new Domain.Country
            {
                Name       = input.Name,
                Alpha2Code = input.Alpha2Code
            };

            context.Countries.Add(country);
            await context.SaveChangesAsync(cancellationToken);

            await eventSender.SendAsync(nameof(CountrySubscriptions.OnCountryAdded), country, cancellationToken);

            return(new AddCountryPayload(country));
        }
        public HttpResponseMessage Create(Domain.Country mCountry)
        {
            HttpResponseMessage response = null;

            try
            {
                if (IsAdminPermission())
                {
                    mCountry = countryService.SaveCountry(mCountry);
                    response = Request.CreateResponse(HttpStatusCode.OK, mCountry);
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.Unauthorized);
                }
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }
            return(response);
        }
 public static AatfContact CreateDefaultContact(Domain.Country country)
 {
     return(new AatfContact("First Name", "Last Name", "Manager", "1 Address Lane", "Address Ward", "Town", "County", "Postcode", country, "01234 567890", "*****@*****.**"));
 }
示例#26
0
 public FormCountryEdit(Domain.Country country) : this()
 {
     Debug.Assert(country != null);
     Entity = country;
 }
示例#27
0
        public override bool Commit()
        {
            if (_country != null)
            {
                long oldid = _country.CountryLanguage;
                long newid = (languageLookUpList.LanguageID);
                if (oldid != newid)
                {
                    Modified = true;
                }
                _country.CountryLanguage = languageLookUpList.LanguageID;
                _country.LanguageID = SharedConsts.NeutralLangId;
                //languageLookUpList.LanguageID;
                    //ClientEnvironment.LogonUser.LanguageID.Value ;

                /*byte b = Convert.ToByte(spinEditBaumaxID.Value);
                if (_country.SystemID1 != b)
                {
                    _country.SystemID1 = b;
                    Modified = true;
                }
                if (_country.SystemID2 != textEditBaumaxDescription.Text)
                {
                    _country.SystemID2 = textEditBaumaxDescription.Text;
                    Modified = true;
                }
                */
                string value = textEditName.Text.Trim();

                if (value != _country.Name)
                {
                    Modified = true;
                    _country.Name = value;
                }
                if (_country.IsNew)
                {
                    Modified = true;
                    try
                    {
                        _country = ClientEnvironment.CountryService.Save(_country);
                    }
                    catch (EntityException ex)
                    {
                        // 2think: what details should we show?
                        // 2think: how to localize?
                        using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex))
                        {
                            form.Text = GetLocalized("CannotSaveCountry");
                            form.ShowDialog(this);
                            return false;
                        }
                    }
                }
                else if (Modified)
                {
                    try
                    {
                        ClientEnvironment.CountryService.SaveOrUpdate(_country);
                    }
                    catch (EntityException ex)
                    {
                        // 2think: what details should we show?
                        // 2think: how to localize?
                        using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex))
                        {
                            form.Text = GetLocalized("CannotSaveCountry");
                            form.ShowDialog(this);
                            return false;
                        }
                    }
                }

                
                if (Modified)
                {
                    if (languageLookUpList.Language != null)
                    {
                        _country.LanguageName = languageLookUpList.Language.Name;
                    }
                }


            }
            return true;
        }
示例#28
0
        public override bool Commit()
        {
            if (_country != null)
            {
                long oldid = _country.CountryLanguage;
                long newid = (languageLookUpList.LanguageID);
                if (oldid != newid)
                {
                    Modified = true;
                }
                _country.CountryLanguage = languageLookUpList.LanguageID;
                _country.LanguageID      = SharedConsts.NeutralLangId;
                //languageLookUpList.LanguageID;
                //ClientEnvironment.LogonUser.LanguageID.Value ;

                /*byte b = Convert.ToByte(spinEditBaumaxID.Value);
                 * if (_country.SystemID1 != b)
                 * {
                 *  _country.SystemID1 = b;
                 *  Modified = true;
                 * }
                 * if (_country.SystemID2 != textEditBaumaxDescription.Text)
                 * {
                 *  _country.SystemID2 = textEditBaumaxDescription.Text;
                 *  Modified = true;
                 * }
                 */
                string value = textEditName.Text.Trim();

                if (value != _country.Name)
                {
                    Modified      = true;
                    _country.Name = value;
                }
                if (_country.IsNew)
                {
                    Modified = true;
                    try
                    {
                        _country = ClientEnvironment.CountryService.Save(_country);
                    }
                    catch (EntityException ex)
                    {
                        // 2think: what details should we show?
                        // 2think: how to localize?
                        using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex))
                        {
                            form.Text = GetLocalized("CannotSaveCountry");
                            form.ShowDialog(this);
                            return(false);
                        }
                    }
                }
                else if (Modified)
                {
                    try
                    {
                        ClientEnvironment.CountryService.SaveOrUpdate(_country);
                    }
                    catch (EntityException ex)
                    {
                        // 2think: what details should we show?
                        // 2think: how to localize?
                        using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex))
                        {
                            form.Text = GetLocalized("CannotSaveCountry");
                            form.ShowDialog(this);
                            return(false);
                        }
                    }
                }


                if (Modified)
                {
                    if (languageLookUpList.Language != null)
                    {
                        _country.LanguageName = languageLookUpList.Language.Name;
                    }
                }
            }
            return(true);
        }
示例#29
0
        private static void AssertUpdated(WeeeContext context, Tuple <Guid, Guid> returnData, SiteAddressData newAddress, Domain.Country newCountry)
        {
            var updatedAddress = (context.WeeeReusedSite
                                  .Where(t => t.WeeeReused.ReturnId == returnData.Item1 &&
                                         t.WeeeReused.Aatf.Id == returnData.Item2).FirstOrDefault()).Address;

            updatedAddress.Should().NotBeNull();
            updatedAddress.Name.Should().NotBeNullOrEmpty();
            updatedAddress.Name.Should().Be(newAddress.Name);
            updatedAddress.Address1.Should().NotBeNullOrEmpty();
            updatedAddress.Address1.Should().Be(newAddress.Address1);
            updatedAddress.Address2.Should().Be(newAddress.Address2);
            updatedAddress.TownOrCity.Should().NotBeNullOrEmpty();
            updatedAddress.TownOrCity.Should().Be(newAddress.TownOrCity);
            updatedAddress.CountyOrRegion.Should().Be(newAddress.CountyOrRegion);
            updatedAddress.Postcode.Should().Be(newAddress.Postcode);
            updatedAddress.CountryId.Should().NotBeEmpty();
            updatedAddress.CountryId.Should().Be(newCountry.Id);
        }
示例#30
0
        private static void AssertUpdated(WeeeContext context, Guid aatfId, AatfContactData newContact, Domain.Country newCountry)
        {
            var updatedContact = context.Aatfs.First(a => a.Id == aatfId).Contact;

            updatedContact.Should().NotBeNull();
            updatedContact.FirstName.Should().NotBeNullOrEmpty();
            updatedContact.FirstName.Should().Be(newContact.FirstName);
            updatedContact.LastName.Should().NotBeNullOrEmpty();
            updatedContact.LastName.Should().Be(newContact.LastName);
            updatedContact.Position.Should().NotBeNullOrEmpty();
            updatedContact.Position.Should().Be(newContact.Position);
            updatedContact.Address1.Should().NotBeNullOrEmpty();
            updatedContact.Address1.Should().Be(newContact.AddressData.Address1);
            updatedContact.Address2.Should().Be(newContact.AddressData.Address2);
            updatedContact.TownOrCity.Should().NotBeNullOrEmpty();
            updatedContact.TownOrCity.Should().Be(newContact.AddressData.TownOrCity);
            updatedContact.CountyOrRegion.Should().Be(newContact.AddressData.CountyOrRegion);
            updatedContact.Postcode.Should().Be(newContact.AddressData.Postcode);
            updatedContact.CountryId.Should().NotBeEmpty();
            updatedContact.CountryId.Should().Be(newCountry.Id);
            updatedContact.Telephone.Should().NotBeNullOrEmpty();
            updatedContact.Telephone.Should().Be(newContact.Telephone);
            updatedContact.Email.Should().NotBeNullOrEmpty();
            updatedContact.Email.Should().Be(newContact.Email);
        }
 public Domain.Country OnCountryAdded([EventMessage] Domain.Country Country) => Country;