コード例 #1
0
        public async Task InsertADMasterCity(ADMasterCity objADMasterCity)
        {
            try
            {
                _Context.ADMasterCities.Add(objADMasterCity);

                await _Context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
        public async Task UpdateADMasterCity(ADMasterCity objADMasterCity)
        {
            try
            {
                _Context.Entry(objADMasterCity).State = Microsoft.EntityFrameworkCore.EntityState.Modified;

                await _Context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #3
0
        public async Task <ActionResult <MasterCityResult> > PostADMasterCity(ADMasterCity objADMasterCity)
        {
            try
            {
                await _IMasterCityInterface.InsertADMasterCity(objADMasterCity);

                return(CreatedAtAction("GetADMasterCity", new { id = objADMasterCity.MasterCityId }, objADMasterCity));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #4
0
        public async Task DeleteADMasterCity(long MasterCityId)
        {
            try
            {
                ADMasterCity objADMasterCity = _Context.ADMasterCities.Find(MasterCityId);
                _Context.ADMasterCities.Remove(objADMasterCity);

                await _Context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #5
0
        public async Task <ActionResult <MasterCityResult> > PutADMasterCity(long id, ADMasterCity objADMasterCity)
        {
            if (id != objADMasterCity.MasterCityId)
            {
                return(BadRequest());
            }


            try
            {
                await _IMasterCityInterface.UpdateADMasterCity(objADMasterCity);

                return(_IMasterCityInterface.GetADMasterCityByID(id));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_IMasterCityInterface.ADMasterCityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(NoContent());
        }