Exemple #1
0
        public async Task <TypedResult <CityDTO> > Update(UpdateRegionCity regionCity)
        {
            try
            {
                if (regionCity.Id.Equals(Guid.Empty))
                {
                    throw new InvalidOperationException(ErrorMessages.ID_IS_REQUIRED);
                }
                RegionCity existsRecord = await regionCityRepo.FindById(regionCity.Id);

                if (existsRecord == null)
                {
                    throw new InvalidOperationException(ErrorMessages.THIS_RECORD_DOES_NOT_EXISTS);
                }

                existsRecord.RegionStateId = regionCity.StateId;
                existsRecord.Title         = regionCity.Title;
                RegionCity result = await regionCityRepo.Update(existsRecord);

                return(new TypedResult <CityDTO>(_mapper.Map <CityDTO>(result)));
            }
            catch (Exception ex)
            {
                return(new TypedResult <CityDTO>(ex));
            }
        }
Exemple #2
0
        public bool AddOrUpdate(RegionCity regionCity, WTCCeresEntities db)
        {
            bool isSaved = true;

            try
            {
                db.RegionCity.AddOrUpdate(regionCity);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                isSaved = false;
            }

            return(isSaved);
        }
Exemple #3
0
 public void PopulateInfo(int CompanyAddressId)
 {
     isCompany = isCompany;
     LoadForm();
     using (var db = new WTCCeresEntities())
     {
         cp = CompanyAddressService.GetById(CompanyAddressId, db);
         rc = cp.RegionCity;
         country1ComboBox1.SelectedValue   = rc.CountryRegion.CountryId;
         cboCity.SelectedValue             = rc.RegionCityId;
         address1TextBox2.Text             = cp.StreetAddress;
         locationDescription1TextBox1.Text = cp.AddressDescription;
         postal1TextBox1.Text = cp.ZipCode;
         phone1TextBox.Text   = cp.Phone;
         fax1TextBox.Text     = cp.Fax;
     }
 }
Exemple #4
0
        public async Task <TypedResult <bool> > Remove(Guid Id)
        {
            try
            {
                RegionCity existsRecord = await regionCityRepo.FindById(Id);

                if (existsRecord == null)
                {
                    throw new InvalidOperationException(ErrorMessages.THIS_RECORD_DOES_NOT_EXISTS);
                }
                Boolean result = await regionCityRepo.Delete(Id);

                return(new TypedResult <Boolean>(result));
            }
            catch (Exception ex)
            {
                return(new TypedResult <Boolean>(ex));
            }
        }
Exemple #5
0
        public async Task <TypedResult <CityDTO> > Add(InsertRegionCity regionCity)
        {
            try
            {
                ICollection <RegionCity> existsRecords = await regionCityRepo
                                                         .GetList(condition : x => x.RegionStateId == regionCity.StateId && x.Title.Equals(regionCity.Title));

                if (existsRecords.Any())
                {
                    throw new InvalidOperationException(ErrorMessages.THIS_RECORD_ALREADY_EXISTS);
                }

                RegionCity entity = _mapper.Map <RegionCity>(regionCity);
                RegionCity result = await regionCityRepo.Add(entity);

                return(new TypedResult <CityDTO>(_mapper.Map <CityDTO>(result)));
            }
            catch (Exception ex)
            {
                return(new TypedResult <CityDTO>(ex));
            }
        }
Exemple #6
0
        public void PopulateInfo(VW_RegionCity vw, bool isNewRecord)
        {
            using (var db = new WTCCeresEntities())
            {
                {
                    var withBlock = cboRegionCode;
                    withBlock.DataSource    = CountryRegionService.GetByCountryId(vw.CountryId, db);
                    withBlock.DisplayMember = "RegionCode";
                    withBlock.ValueMember   = "CountryRegionId";
                }
            }

            if (isNewRecord)
            {
                tbCityCode.Text             = "";
                tbCityName.Text             = "";
                cboRegionCode.SelectedIndex = 0;
                lblCountry.Text             = vw.CountryName;
                cr           = new CountryRegion();
                rc           = new RegionCity();
                cr.CountryId = vw.CountryId;
            }
            else
            {
                using (var db = new WTCCeresEntities())
                {
                    cr = CountryRegionService.GetById(vw.CountryRegionId, db);
                    rc = new RegionCity();
                    rc = RegionCityService.GetById(vw.RegionCityId, db);
                    cboRegionCode.SelectedValue = vw.CountryRegionId;
                    tbCityCode.Text             = vw.CityCode;
                    lblCountry.Text             = vw.CountryName;
                    tbCityName.Text             = vw.CityName;
                }
            }
        }
Exemple #7
0
 public bool AddOrUpdate(RegionCity regionCity, WTCCeresEntities db)
 {
     return(repository.AddOrUpdate(regionCity, db));
 }