public async Task UpdateADMasterFunction(ADMasterFunction objADMasterFunction)
 {
     try
     {
         _Context.Entry(objADMasterFunction).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         await _Context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public async Task InsertADMasterFunction(ADMasterFunction objADMasterFunction)
        {
            try
            {
                _Context.ADMasterFunctions.Add(objADMasterFunction);

                await _Context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public async Task DeleteADMasterFunction(long MasterFunctionId)
        {
            using (var transaction = _Context.Database.BeginTransaction())
            {
                try
                {
                    _Context.ADProfileTaskMappings.RemoveRange(_Context.ADProfileTaskMappings.Where(a => a.MasterFunctionId == MasterFunctionId));
                    await _Context.SaveChangesAsync();

                    ADMasterFunction objADMasterFunction = _Context.ADMasterFunctions.Find(MasterFunctionId);
                    _Context.ADMasterFunctions.Remove(objADMasterFunction);

                    await _Context.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                }
            }
        }
        public async Task <ActionResult <MasterFunctionResult> > PostADMasterFunction(ADMasterFunction objADMasterFunction)
        {
            try
            {
                await _IMasterFunctionInterface.InsertADMasterFunction(objADMasterFunction);

                return(CreatedAtAction("GetADMasterFunction", new { id = objADMasterFunction.MasterFunctionId }, objADMasterFunction));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public async Task <ActionResult <MasterFunctionResult> > PutADMasterFunction(long id, ADMasterFunction objADMasterFunction)
        {
            if (id != objADMasterFunction.MasterFunctionId)
            {
                return(BadRequest());
            }

            try
            {
                await _IMasterFunctionInterface.UpdateADMasterFunction(objADMasterFunction);

                return(_IMasterFunctionInterface.GetADMasterFunctionByID(id));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_IMasterFunctionInterface.ADMasterFunctionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(NoContent());
        }