コード例 #1
0
        public async Task<bool> Update(VehicleOganize item)
        {
            var ogn = await IdExist(item.Id);

            ogn.Name = item.Name;

            _db.Entry(ogn).State = EntityState.Modified;
            try
            {
                await _db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException exception)
            {
                throw new DbUpdateConcurrencyException(exception.Message);
            }

            return true;
        }
コード例 #2
0
        public async Task<VehicleOganize> Add(VehicleOganize item)
        {
            var ogn = new VehicleOganize
            {
                Name = item.Name,
            };

            ogn = _db.VehicleOganizes.Add(ogn);
            try
            {
                await _db.SaveChangesAsync();
                return ogn;
            }
            catch (DbUpdateConcurrencyException exception)
            {
                throw new DbUpdateConcurrencyException(exception.Message);
            }
        }