Beispiel #1
0
        public async Task <bool> UpdateState(StateDVM entity)
        {
            bool result = false;

            if (entity != null)
            {
                State c = await stateRepository.GetAsync(entity.Code);

                if (c != null)
                {
                    c.Name        = entity.Name;
                    c.CountryCode = entity.CountryCode;
                    try
                    {
                        await stateRepository.UpdateAsync(c);

                        result = true;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            return(result);
        }
Beispiel #2
0
        public async Task <bool> UpdateStateAsync(StateDVM entity)
        {
            bool result = false;

            if (entity != null)
            {
                State d = StateRepository.Get(entity.Code);
                if (d != null)
                {
                    d.CountryId  = entity.CountryId;
                    d.Name       = entity.Name;
                    d.RegionCode = entity.RegionCode;

                    try
                    {
                        await StateRepository.UpdateAsync(d);

                        result = true;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            return(result);
        }
Beispiel #3
0
        public async Task <StateDVM> GetStateByID(object Id)
        {
            StateDVM cdvm = new StateDVM();

            if (Id != null)
            {
                State c = await stateRepository.GetAsync(Id);

                if (c != null)
                {
                    cdvm = mapper.Map <StateDVM>(c);
                }
            }
            return(cdvm);
        }
Beispiel #4
0
        public async Task <bool> AddState(StateDVM entity)
        {
            bool id = false;

            if (entity != null)
            {
                State c = mapper.Map <State>(entity);
                try
                {
                    var obj = await stateRepository.InsertAsync(c);

                    id = true;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(id);
        }
Beispiel #5
0
        public async Task <string> AddStateAsync(StateDVM entity)
        {
            string code = "";

            if (entity != null)
            {
                State c = mapper.Map <State>(entity);
                try
                {
                    var obj = await StateRepository.InsertAsync(c);

                    code = obj.Code;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(code);
        }
Beispiel #6
0
        public async Task <StateDVM> GetStateByIDAsync(object Id)
        {
            try
            {
                StateDVM pdvm = null;
                if (Id != null)
                {
                    State d = await StateRepository.GetAsync(Id);

                    if (d != null)
                    {
                        pdvm = mapper.Map <StateDVM>(d);
                    }
                }
                return(pdvm);
            }
            catch (Exception e)
            {
                throw e;
            }
        }