public async Task InsertADMasterTypeOfDevice(ADMasterTypeOfDevice objADMasterTypeOfDevice)
        {
            try
            {
                _Context.ADMasterTypeOfDevices.Add(objADMasterTypeOfDevice);

                await _Context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public async Task UpdateADMasterTypeOfDevice(ADMasterTypeOfDevice objADMasterTypeOfDevice)
        {
            try
            {
                _Context.Entry(objADMasterTypeOfDevice).State = Microsoft.EntityFrameworkCore.EntityState.Modified;

                await _Context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public async Task DeleteADMasterTypeOfDevice(long MasterTypeOfDeviceId)
        {
            try
            {
                ADMasterTypeOfDevice objADMasterTypeOfDevice = _Context.ADMasterTypeOfDevices.Find(MasterTypeOfDeviceId);
                _Context.ADMasterTypeOfDevices.Remove(objADMasterTypeOfDevice);

                await _Context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #4
0
        public async Task <ActionResult <MasterTypeOfDeviceResult> > PostADMasterTypeOfDevice(ADMasterTypeOfDevice objADMasterTypeOfDevice)
        {
            try
            {
                await _IMasterTypeOfDeviceInterface.InsertADMasterTypeOfDevice(objADMasterTypeOfDevice);

                return(CreatedAtAction("GetADMasterTypeOfDevice", new { id = objADMasterTypeOfDevice.MasterTypeOfDeviceId }, objADMasterTypeOfDevice));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #5
0
        public async Task <ActionResult <MasterTypeOfDeviceResult> > PutADMasterTypeOfDevice(long id, ADMasterTypeOfDevice objADMasterTypeOfDevice)
        {
            if (id != objADMasterTypeOfDevice.MasterTypeOfDeviceId)
            {
                return(BadRequest());
            }

            try
            {
                await _IMasterTypeOfDeviceInterface.UpdateADMasterTypeOfDevice(objADMasterTypeOfDevice);

                return(_IMasterTypeOfDeviceInterface.GetADMasterTypeOfDeviceByID(id));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_IMasterTypeOfDeviceInterface.ADMasterTypeOfDeviceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(NoContent());
        }