public async Task <ActionResult <MasterProfileResult> > PostADMasterProfile(ADMasterProfile objADMasterProfile)
        {
            try
            {
                await _IMasterProfileInterface.InsertADMasterProfile(objADMasterProfile);

                return(CreatedAtAction("GetADMasterProfile", new { id = objADMasterProfile.MasterProfileId }, objADMasterProfile));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public async Task UpdateADMasterProfile(ADMasterProfile objADMasterProfile)
        {
            try
            {
                _Context.Entry(objADMasterProfile).State = Microsoft.EntityFrameworkCore.EntityState.Modified;

                await _Context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public async Task InsertADMasterProfile(ADMasterProfile objADMasterProfile)
        {
            try
            {
                _Context.ADMasterProfiles.Add(objADMasterProfile);

                await _Context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public async Task DeleteADMasterProfile(long MasterProfileId)
        {
            using (var transaction = _Context.Database.BeginTransaction())
            {
                try
                {
                    //Delete All related record belongs to MasterProfileID from ADProfileTaskMappings Table
                    _Context.ADProfileTaskMappings.RemoveRange(_Context.ADProfileTaskMappings.Where(a => a.MasterProfileId == MasterProfileId));
                    await _Context.SaveChangesAsync();

                    ADMasterProfile objADMasterProfile = _Context.ADMasterProfiles.Find(MasterProfileId);

                    _Context.ADMasterProfiles.Remove(objADMasterProfile);
                    await _Context.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                }
            }
        }
        public async Task <ActionResult <MasterProfileResult> > PutADMasterProfile(long id, ADMasterProfile objADMasterProfile)
        {
            if (id != objADMasterProfile.MasterProfileId)
            {
                return(BadRequest());
            }


            try
            {
                await _IMasterProfileInterface.UpdateADMasterProfile(objADMasterProfile);

                return(_IMasterProfileInterface.GetADMasterProfileByID(id));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_IMasterProfileInterface.ADMasterProfileExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(NoContent());
        }