예제 #1
0
        public async Task <bool> UpdateCountry(CountryDVM Country)
        {
            bool result = false;

            if (Country != null)
            {
                Country c = await countryRepository.GetAsync(Country.Code);

                if (c != null)
                {
                    c.Name = Country.Name;
                    try
                    {
                        await countryRepository.UpdateAsync(c);

                        result = true;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            return(result);
        }
예제 #2
0
        public async Task <CountryDVM> GetCountryByID(object Id)
        {
            CountryDVM cdvm = new CountryDVM();

            if (Id != null)
            {
                Country c = await countryRepository.GetAsync(Id);

                if (c != null)
                {
                    cdvm = mapper.Map <CountryDVM>(c);
                }
            }
            return(cdvm);
        }
예제 #3
0
        public async Task <bool> AddCountry(CountryDVM Country)
        {
            bool id = false;

            if (Country != null)
            {
                Country c = mapper.Map <Country>(Country);
                try
                {
                    var obj = await countryRepository.InsertAsync(c);

                    id = true;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(id);
        }
예제 #4
0
        public async Task <CountryDVM> GetCountryByIDAsync(object Id)
        {
            try
            {
                CountryDVM cdvm = null;
                if (Id != null)
                {
                    Country d = await countryRepository.GetAsync(Id);

                    if (d != null)
                    {
                        cdvm = mapper.Map <CountryDVM>(d);
                    }
                }
                return(cdvm);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #5
0
        public async Task <bool> UpdateCountryAsync(CountryDVM entity)
        {
            bool result = false;

            if (entity != null)
            {
                Country d = countryRepository.Get(entity.Code);
                if (d != null)
                {
                    d.Name = entity.Name;
                    try
                    {
                        await countryRepository.UpdateAsync(d);

                        result = true;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            return(result);
        }